If I run the code below it works fine. First test1 and then test2.
As long as the width of the columns show the whole number in the cells!!
But if I make column A as narrow as the number change to ## and hide column B, test2 will not find the first and the second number?!
(I found a workaround using "match", not tested yet..)
As long as the width of the columns show the whole number in the cells!!
But if I make column A as narrow as the number change to ## and hide column B, test2 will not find the first and the second number?!
(I found a workaround using "match", not tested yet..)
Code:
Sub test1()
Cells(1, 1) = 12345
Cells(1, 2) = 23456
Cells(1, 3) = 34567
Dim rng As Range
Set rng = Range(Cells(1, 1), Cells(1, 3))
rng.Copy Destination:=Cells(1, 5)
End Sub
Sub test2()
Dim rngFind As Range
For c = 5 To 7
Set rngFind = Range(Cells(1, 1), Cells(1, 3)).Find(What:=Cells(1, c), LookIn:=xlValues, LookAt:=xlWhole)
If rngFind Is Nothing Then
MsgBox "Cant find " & Cells(1, c)
Else
MsgBox "Found " & rngFind
End If
Next c
End Sub