cells problem

W

Wu

I write a macro to find a pair of data at different cells in a worksheet.

After finding, I would like to get the x of the cells or Y of the
cells..........
for example, the found data at cells(2,2) and cells(3,4)
I want to write a macro to get the 2 and 3 ,
L1 = x of cells 1
L2 = x of cells 2

Can I use function to get the loacation of the cells ?
How to write in macro to get the x or y , or x and y of a cell?
 
G

Gary''s Student

Here is an example with one cell andone value. Let's say we are looking for
"happiness":

Sub findit()
v = "happiness"
For Each r In ActiveSheet.UsedRange
If r.Value = v Then
x = r.Row
y = r.Column
MsgBox ("happiness can be found in cell(" & x & "," & y & ")")
End If
Next
End Sub
 
Top