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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

variable sheet name 6
Help with a macro 4
Copying and pasting with a macro 1
coding error I don't know how to debug? 1
Cell Referencing 5
Macro Modification Help 1
VBA Formula Help 6
Cant merge cell 2

Top