ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   When (https://www.excelbanter.com/excel-programming/428900-when.html)

kirkm[_8_]

When
 
When you pass Target.Address as a parameter e.g $I$3466
is there a system command to get the row and column from that?
(I know it's dead easy to DIY but just wondering).

Thanks - Kirk

macropod[_2_]

When
 
Hi Kirk,

Try:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox "Column: " & Split(Target.Address, "$")(1) & _
vbCrLf & "Row: " & Split(Target.Address, "$")(2)
End Sub

or:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox "Column: " & Target.Column & vbCrLf & "Row: " & Target.Row
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"kirkm" wrote in message ...
When you pass Target.Address as a parameter e.g $I$3466
is there a system command to get the row and column from that?
(I know it's dead easy to DIY but just wondering).

Thanks - Kirk


Per Jessen

When
 
Hi Kirk.

MyRow=Target.Row
MyCol=Target.Column

Hopes this helps.

---
Per

"kirkm" skrev i meddelelsen
...
When you pass Target.Address as a parameter e.g $I$3466
is there a system command to get the row and column from that?
(I know it's dead easy to DIY but just wondering).

Thanks - Kirk



Rick Rothstein

When
 
Your question is not entirely clear. What do you mean when you say "pass
Target.Address"... do you mean pass that into another subroutine or
function? Or did you mean pass the String value $I$3466 into another
subroutine or function? Or did you mean as macropod indicated... working
with the Target argument of an event procedure within the event procedure.
Either of the first two can be done by using the address as an argument to
the Range object and then querying it for the row and column. For example,
assuming Arg is the name of the argument in the subroutine or function that
you are passing either Target.Address or "$I$3466" into...

MsgBox "Column: " & Range(Arg).Column & vbCrLf & "Row: " & Range(Arg).Row

--
Rick (MVP - Excel)


"kirkm" wrote in message ...
When you pass Target.Address as a parameter e.g $I$3466
is there a system command to get the row and column from that?
(I know it's dead easy to DIY but just wondering).

Thanks - Kirk



kirkm[_8_]

When
 
On Mon, 25 May 2009 17:03:32 +1200, kirkm wrote:

Thanks very much everyone. Yes, it wasn't very well put,
the question. It was after being passed to a function
where I wanted the column and row values, without the $.

I changed to sending Target.Row in instead of Target.Address,
but Rick has the answer I was seeking...

line = range("$I$3266").Row (or .Column)

Neater and shorter than what I had, or Split (nice command!)

Cheers - Kirk


All times are GMT +1. The time now is 09:05 AM.

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