Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Determining cursor position in a named range

what macro code do I use to find the row and column position of the cursor in
a named range table on a worksheet?

If the cursor is not exatactly in the named range, I'd like to determine the
row if that is win the table, the column if that is in the table, or if both
are out of the table range.

I appreciate your help, -John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Determining cursor position in a named range

On Feb 6, 9:12*am, John wrote:
what macro code do I use to find the row and column position of the cursor in
a named range table on a worksheet?

If the cursor is not exatactly in the named range, I'd like to determine the
row if that is win the table, the column if that is in the table, or if both
are out of the table range.

I appreciate your help, -John


John,

You can use the Row and Column property of a Range object. For
example, the following code will print the results to the Immediate
Window.

'This is for the ActiveCell
Debug.Print ActiveCell.Row
Debug.Print ActiveCell.Column

'This is for a specified range location
Debug.Print Range("AA5").Row
Debug.Print Range("AA5").Column

Matt
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Determining cursor position in a named range

Your question (as to what you want reported back to you) is not very clear
to me. Does this do what you want...

Sub WhereIsActiveCell()
Dim Status As String
If Intersect(Range("RngName"), ActiveCell.EntireRow) Is Nothing Then
Status = "ActiveCell's Row is not within the Named Range."
Else
Status = "The ActiveCell's Row is located within the Named Range."
End If
If Intersect(Range("RngName"), ActiveCell.EntireColumn) Is Nothing Then
Status = Status & vbLf & vbLf & _
"ActiveCell's Column is not within the Named Range."
Else
Status = Status & vbLf & vbLf & _
"The ActiveCell's Column is located within the Named Range."
End If
MsgBox Status
End Sub

--
Rick (MVP - Excel)


"John" wrote in message
...
what macro code do I use to find the row and column position of the cursor
in
a named range table on a worksheet?

If the cursor is not exatactly in the named range, I'd like to determine
the
row if that is win the table, the column if that is in the table, or if
both
are out of the table range.

I appreciate your help, -John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Determining cursor position in a named range

Rick, I apologized for the lack of clarity. Sometimes it's hard to clearly
articulate a question. That said, I messed w/ your code and found the
following gives me the row in the table where the cursor is, or a msg if it
is outside the table range.
On Error Resume Next
CursorRow = Intersect(Range(Table), ActiveCell).Row
FirstTableRow = Intersect(Range(Table), Range(Table)(1, 1)).Row
If Err < 0 Then
MsgBox "Cursor is not positioned inside table."
Exit Sub
End If
On Error GoTo 0
CursorTableRow = CursorRow - FirstTableRow + 1
This seems like a lot of code to find CursorTableRow, but it works.

Thx so much for your patience and help, John

"Rick Rothstein" wrote:

Your question (as to what you want reported back to you) is not very clear
to me. Does this do what you want...

Sub WhereIsActiveCell()
Dim Status As String
If Intersect(Range("RngName"), ActiveCell.EntireRow) Is Nothing Then
Status = "ActiveCell's Row is not within the Named Range."
Else
Status = "The ActiveCell's Row is located within the Named Range."
End If
If Intersect(Range("RngName"), ActiveCell.EntireColumn) Is Nothing Then
Status = Status & vbLf & vbLf & _
"ActiveCell's Column is not within the Named Range."
Else
Status = Status & vbLf & vbLf & _
"The ActiveCell's Column is located within the Named Range."
End If
MsgBox Status
End Sub

--
Rick (MVP - Excel)


"John" wrote in message
...
what macro code do I use to find the row and column position of the cursor
in
a named range table on a worksheet?

If the cursor is not exatactly in the named range, I'd like to determine
the
row if that is win the table, the column if that is in the table, or if
both
are out of the table range.

I appreciate your help, -John



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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining if a named range exists a Excel Programming 2 January 5th 06 01:39 PM
Copy named range contents to activecell position Neal Excel Programming 2 October 28th 04 02:20 PM
How to get the position of a cell in Excel named range? Kalpesh Shah Excel Programming 0 July 10th 03 09:07 AM
How to get the position of a cell in Excel named range? [email protected] Excel Programming 0 July 10th 03 03:14 AM
How to get the position of a cell in Excel named range? acw Excel Programming 0 July 10th 03 02:57 AM


All times are GMT +1. The time now is 03:39 PM.

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

About Us

"It's about Microsoft Excel"