LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to I return the position of a selected cell in a range?

Hi all,

I am trying to create a routine in VBA using which I should be able to
do the following:

- Lets say I have 10 column headers
- They have long descripotions (e.g. "Time spent on.....") but a short
header name (e.g. TM1).
- The descriptions in the corresponding columns in a different row
(hidden)

I was to be able to display a comment with the appropriate text
whenever the user clicks on a header cell.

I am half way there. Code attached: What I can't figure out is how to
return the position of the cell that the user selects so that I can
refer to the right text for the comment. Any help is highly
appreciated.

Code-

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim newtext$
Dim Addr$
Dim RangeToCheck As Range
Dim RangeComment As Range
Dim isect As Range
Dim intRow As Integer
Dim intCol As Integer

If Target.Cells.Count 1 Then
Exit Sub

Set RangeToCheck = ThisWorkbook.Sheets("Rep Data").Range("headers")
RangeComment = ThisWorkbook.Sheets("Rep Data").Range("headertext")
Set isect = Application.Intersect(Target, RangeToCheck)

If isect Is Nothing Then Exit Sub
Addr = isect.Address
'intCol = isect.Row
ThisWorkbook.Sheets("Rep Data").Range("row").Value = Addr
'ThisWorkbook.Sheets("Rep Data").Range("col").Value = intCol

'newtext = RangeComment.(intCol).Value
'isect.Comment.Text newtext
End If
End Sub

 
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
Position selected cell nobbyknownowt Setting up and Configuration of Excel 2 February 1st 07 08:00 AM
Formula to return cell position AJPendragon Excel Worksheet Functions 1 February 6th 06 09:34 PM
Default cursor/selected cell position after protecting Stilla Excel Worksheet Functions 0 December 8th 05 02:28 PM
find the first blank cell in a range and return me it's position steve alcock Links and Linking in Excel 2 May 13th 05 09:03 AM
Returning Position Points from the currently selected cell Keys1970 Excel Programming 2 December 30th 04 07:11 PM


All times are GMT +1. The time now is 01:29 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"