#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 166
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 166
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"