Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select column cells to the left/right of active selection - an example

Here is another useful tip:

An alternative would be to hold down the shift key and click in the cell to
which you want to extend the selection.

This would minimize the need of having to go to Tools=Macro=Macros and
running this macro or using a shortcut key combination, figuring out the
number of columns left or right you want to go and making sure you included
the negative sign if going to the left, entering that information in an
input box and clicking the OK button. If bad mouse skills cause too much to
be selected, clicking in the original cell and trying again will work. If
you select short of the desired mark, continue to hold the shift key and try
again.

If code is desired, this is more compact:

Sub RangeSelectionOffset()

'Selects column cells to the left or the right of the
'active selection(s). This VBA Procedure can work
'on non-contiguous ranges.
'You are prompted for the column number offset either left (-)
'or right (+).

Dim AddressOffset1 As Range
Dim ColumnOffsetNumber As Integer

On Error Resume Next
Set AddressOffset1 = ActiveCell(1)
ColumnOffsetNumber = Application.InputBox( _
prompt:="Enter # of columns to offset " & vbNewLine & _
"select. Remember a positive (+) value " & vbNewLine & _
"SELECTS TO THE RIGHT, a negative (-) " & vbNewLine & _
"value SELECTS TO THE LEFT.", _
Title:="Select Rows To The Left(-) or The Right(+)", _
Default:=-1, Type:=1) 'type 1 is Number


'Test for a negative (-) column offset number

If ColumnOffsetNumber < 0 Then
Set AddressOffset1 = AddressOffset1 _
.Offset(0, ColumnOffsetNumber)
End If
AddressOffset1.Resize(1, _
Abs(ColumnOffsetNumber) + 1).Select
End Sub



--
Regards,
Tom Ogilvy



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
how to select entire row and column in a sigle cell selection sabu varoor Excel Worksheet Functions 3 December 22nd 08 05:19 PM
Select Active Cells Umbu Excel Worksheet Functions 0 June 24th 08 02:03 PM
how to select fewer cells without canceling original selection excelconfusedgirl Excel Discussion (Misc queries) 7 August 10th 07 11:06 PM
I do not see the selection colour when I select some cells dev Excel Discussion (Misc queries) 1 August 17th 06 01:40 PM
Tools/Options/Charts-Active cells is dimmed. Want to select leave teds Charts and Charting in Excel 9 April 13th 06 04:02 PM


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