Excel VBA:如果找到的匹配突出显示在D列中自动找到匹配,如何从用户获取输入并比较D列中的完全匹配?是否可以使用Excel 2013?
请帮助这对我很有帮助....
答案 0 :(得分:0)
通过完全匹配,您正在谈论区分大小写的匹配,不是吗?如果是这样,应该这样做:
Function findValue()
Dim Value As Variant
Dim Sheetname As String
Value = InputBox("Enter Value:", "Input")
Sheetname = "ENTER SHEETNAME HERE"
'Sheets(Sheetname).Columns("D:D").Select
Dim Cell As Variant
'Search in Column D | MatchCase True = case sensitive
Set Cell = Sheets(Sheetname).Columns("D:D").Find(What:=Value, After:=Sheets(Sheetname).Range("D1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False)
If Not Cell Is Nothing Then
'Value is found, Highlight Cell
Sheets(Sheetname).Range(Cell.Address).Interior.ColorIndex = 4
Else
'Value Not found
MsgBox "Not Found"
End If
End Function
否则,您必须将MatchCase选项更改为False