これは非常に基本的な質問です。私は vba の専門家ではないので、怒鳴らないでください。
それでは、以下のvba関数を作成しました
Public Function GetDuplicateCount(value As String) As Integer
Dim counter As Integer
counter = 0
With Worksheets(1).Range("A:A")
Set c = .Find(value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
counter = counter + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing
End If
End With
GetDuplicateCount = counter
End Function
以下は私のExcelの値です
あ
1 IND
2 アメリカ
3缶
4 IND
5缶
6 アメリカ
任意の値で検索するたびに、不明な値が返されます。機能に問題はありますか?
例: GetDuplicateCount("IND")