下面是我的密码。我想要的是,代码应该忽略字母的情况,不管是小写还是两者兼而有之。
Private Sub CommandButton1_Click()
Dim ws As Worksheet, tbl As ListObject, row As ListRow
Set ws = Sheets("Sheet1")
Set tbl = ws.ListObjects("Table2")
Dim intValueToFind As String, intValueToFind1 As String, rng As Range, rng1 As Range
Set rng = tbl.ListColumns(1).DataBodyRange
Set rng1 = tbl.ListColumns(2).DataBodyRange
intValueToFind = LCase(Me.ComboBox1.Value)
intValueToFind1 = LCase(Me.TextBox2.Value)
If Not rng Is Nothing Then
For Each rng In rng
If LCase(rng.Value) = intValueToFind Then
If Not rng1 Is Nothing Then
For Each rng1 In rng1
If LCase(rng1.Value) = intValueToFind1 Then
MsgBox ("Group Head under this Account Head already Exist. Please enter the Unique Name...")
Exit Sub
End If
Next rng1
End If
End If
Next rng
End If
Set row = tbl.ListRows.Add
row.Range(1, 1).Value = Me.ComboBox1.Value
row.Range(1, 2).Value = Me.TextBox2.Value
End Sub请检查以上代码,并告知我在哪里出错。
发布于 2016-11-25 13:07:10
只需将两边投到下边(或上边):
If LCase(rng.Value) = LCase(intValueToFind) Thenhttps://stackoverflow.com/questions/40805625
复制相似问题