#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Selection

Hi Everyone:

In excel 2003 VBA, I am writing a sub in a module. Is there a way of
knowing when a selection was made, was it left to right or right to left? I
need to know which column the user clicked first and then dragged the mouse
to create the selection. I think I have to use the ActiveCell.Address
property, is that correct? Thanks for all your help.

Bob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Selection

You should be able to build whatever final solution you would like to
achieve around this code...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim StartCell As Range
Dim Direction As String
If Selection.Count 1 Then
Set StartCell = Range(Split(Selection.Address, ":")(0))
If Selection.Columns.Count 1 Then
If ActiveCell.Column = StartCell.Column Then
Direction = "Left-to-Right"
Else
Direction = "Right-to-Left"
End If
End If
If Selection.Rows.Count 1 And Selection.Columns.Count 1 Then
Direction = Direction & " and "
End If
If Selection.Rows.Count 1 Then
If ActiveCell.Row = StartCell.Row Then
Direction = Direction & "Top-to-Bottom"
Else
Direction = Direction & "Bottom-to-Top"
End If
End If
MsgBox Direction
End If
End Sub

--
Rick (MVP - Excel)


"Bob" wrote in message
...
Hi Everyone:

In excel 2003 VBA, I am writing a sub in a module. Is there a way of
knowing when a selection was made, was it left to right or right to left?
I need to know which column the user clicked first and then dragged the
mouse to create the selection. I think I have to use the
ActiveCell.Address property, is that correct? Thanks for all your help.

Bob


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Selection

Thank you Rick. That was great.

Bob

"Rick Rothstein" wrote in message
...
You should be able to build whatever final solution you would like to
achieve around this code...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim StartCell As Range
Dim Direction As String
If Selection.Count 1 Then
Set StartCell = Range(Split(Selection.Address, ":")(0))
If Selection.Columns.Count 1 Then
If ActiveCell.Column = StartCell.Column Then
Direction = "Left-to-Right"
Else
Direction = "Right-to-Left"
End If
End If
If Selection.Rows.Count 1 And Selection.Columns.Count 1 Then
Direction = Direction & " and "
End If
If Selection.Rows.Count 1 Then
If ActiveCell.Row = StartCell.Row Then
Direction = Direction & "Top-to-Bottom"
Else
Direction = Direction & "Bottom-to-Top"
End If
End If
MsgBox Direction
End If
End Sub

--
Rick (MVP - Excel)


"Bob" wrote in message
...
Hi Everyone:

In excel 2003 VBA, I am writing a sub in a module. Is there a way of
knowing when a selection was made, was it left to right or right to left?
I need to know which column the user clicked first and then dragged the
mouse to create the selection. I think I have to use the
ActiveCell.Address property, is that correct? Thanks for all your help.

Bob




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
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Copy Selection - Paste Selection - Delete Selection Uninvisible Excel Programming 2 October 25th 07 01:31 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Combo Box selection only shows bound column info after selection made. Coby Excel Programming 1 October 18th 07 02:04 AM
How to create a selection list then display the selection in a cell [email protected] Excel Programming 0 August 1st 07 03:01 PM


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