ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   cells problem (https://www.excelbanter.com/excel-discussion-misc-queries/187869-cells-problem.html)

Wu

cells problem
 
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?



Gary''s Student

cells problem
 
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
--
Gary''s Student - gsnu200786


"Wu" wrote:

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?



dksaluki

cells problem
 
....or
If r.Value = v Then
MsgBox r.Address
End If




All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com