In my excel sheet, Value of cell A1 is 1000 whereas that of cell B1 is 10000.
I am trying to find column no. of a cell that contains "1000".
Column no. output I want is 1 (i.e. cell A1) but I am getting output as 2 with below code (referring to value 10000 in cell B1). On the other hand in cell B1 if I replace 10000 by say 10100, I get output of below code as 1.
May I know what change do I need to do in code to get desired output?
*
Sub Find_Number()
Dim Find As Range
Set Find = Range(Cells(1, 1), Cells(1, 5)).Find("1000")
Debug.Print Find.Column
End Sub
*
Range.Find: After, LookIn, LookAt, etc.. After should be the last cell.Application.Matchis another option.LookIn:= xlWhole. I would renameFindtoFoundto avoid using a key word as variable. Also makes statements like these intuitive:If Not Found is Nothing Then Debug.Print Found.Column