-
Hi Killian,
Sorry for the delay with my reply. Thanks for the explanation, it did the trick.
After some playing around I ended up with this:-
[vba]Sub FindCodesV3()
'
'multiple entries version
'
Dim rng1 As Range
Dim cel1 As Range
Dim counter As Integer
counter = 2
Set rng1 = Worksheets("Image Names").Range("A2:A101")
For Each cel1 In rng1
If cel1.Value <> "0" Then
With Worksheets(3).Range("d2:d2001") 'CHANGE THE 'Worksheets(3)'
Set c = Columns("D").Find(What:=cel1.Value, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If Not c Is Nothing Then
firstAddress = c.Address
'MsgBox "firstAddress = " & firstAddress
Worksheets("Image Names").Cells(counter, 2).Value = c
Set c = .FindNext(c)
secondAddress = c.Address
'MsgBox "secondAddress = " & secondAddress
If secondAddress <> firstAddress Then
Worksheets("Image Names").Cells(counter, 3).Value = c
End If
Else
Worksheets("Image Names").Cells(counter, 2).Value = "0"
End If
End With
End If
counter = counter + 1
Next cel1
End Sub[/vba]
It works fine and fills the required columns with the relevant search data. I'm going to take it further so the search range values are picked up from cells on the worksheet.
I'd appreciate any help on tidying up the code if possible, not sure if this is the best way to have done this task.
Thanks again,
Nick
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules