I have some code that currently searches column A for the mention of 27 and copies the cells in column B, same row as 27 into Column C. Is there a way to modify this code to copy the values of cells when 27 is not in Column A. Does that make sense?
The sample worksheet contains the number 27 in Cells (A1:A30) and the number 1 in Cells (B1:B30); except in A5, where it's 28, and B5 where it's 2. I know, in this case, i could search for 28, but the main reason for this code is that there will be more than 1 value that could be different i.e. a 26 or 22 , as well as 30 etc.
When I was thinking about this, I assumed that I had to change the line If Not foundCel Is Nothing Then
to something different, but I may be barking up the wrong tree here.
Option Explicit
Sub Button1_Click()
Dim v As Long
v = 1
findStr = "27"
Set foundCel = Range("A:A").Find(What:=findStr)
If Not foundCel Is Nothing Then 'Yes'
firstAddress = foundCel.Address
Do
Range("C" & v).Value = foundCel.Offset(0, 1).Value
Set foundCel = Range("A:A").FindNext(foundCel)
v = v + 1
Loop While Not foundCel Is Nothing And foundCel.Address <> firstAddress
End If
End Sub
Thanks for any help you can provide.