Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Limiting selection in a cell AND linking that selection to a list | Excel Discussion (Misc queries) | |||
Copy Selection - Paste Selection - Delete Selection | Excel Programming | |||
Copy Selection - Transpose Selection - Delete Selection | Excel Discussion (Misc queries) | |||
Combo Box selection only shows bound column info after selection made. | Excel Programming | |||
How to create a selection list then display the selection in a cell | Excel Programming |