以下是我的代码。我想要的是代码应该忽略字母表的情况,无论它是小资本还是两者兼而有之。
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
请仔细阅读上述代码并告知我误解的地方。
答案 0 :(得分:0)
将两侧投射到小写字母(或大写字母):
If LCase(rng.Value) = LCase(intValueToFind) Then