我正在为我正在研究的数据库建立一个搜索功能。我遇到的问题是,仅根据数据库的分类性质,数据库中就有很多重复项。就是说,我的搜索输出了许多相同的值并列出了它们。我在VBA上还真的很新,所以我不太了解如何解决此问题。任何帮助,将不胜感激。预先感谢...。
Private Sub Command()
Dim FirstAddress As String
Dim Number As String
Dim Rng As Range
Dim LastRow As Long
Dim Number1 As String
Dim I As Integer
ISO = InputBox("Enter Numbers Column 1: ", "Numbers")
If Trim(Number) <> "" Then
With Sheets("Sheet1").Range("A:B")
.Interior.ColorIndex = xlColorIndexNone
Set Rng = .Find(What:=ISO)
If Not Rng Is Nothing Then
FirstAddress = Rng.Address
Do
Rng.Interior.ColorIndex = 6
Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address <> FirstAddress
End If
For I = 1 To 5550
If Cells(I, 1).Interior.ColorIndex = 6 Then
Number1 = Number1 & Cells(I, 2).value & vbNewLine
Cells(I, 2).Interior.ColorIndex = 6
End If
Next I
End With
End If
MsgBox "Numbers: " & Number1 & vbNewLine
End Sub