VBA中的字典类型需要添加Microsoft Scripting Runtime引用,其中引用添加在Tools菜单下完成。然后就可以创建和使用字典类型了。
Dim names As Dictionary
Set names = New Dictionary
names.Add name, items
If names.Exists(temp) Then
temp = names.item(temp)
End If
names.RemoveAll
Set names = Nothing
正则表达式的使用需要Microsoft VBScript Regular Expression 5.5 引用,也是通过Tools菜单完成添加。
Dim mr As New RegExp
With mr
.Global = True
.IgnoreCase = True
.Pattern = "Month\s?\W?$"
End With
If mr.Test(Trim(ActiveSheet.Cells(r, c).Text)) Then
'*****
End If
这里使用正则表达式匹配以"Month"或"Month:"结尾的的字符串