Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Selecting 2 cells together

I am trying to do the following in a macro:

1. For all occupied cells in one column
2. Jump down to the next occupied cell
3. Select that cell AND the one to the left of it
4. Cut
5. Move the selection one cell to the left.
6. Paste.

The following code does all of that except for step 3. It seems such a
simple thing, but I can't find it in the Google archive.

Can someone help?

Sub Line_up_cols()
'
' Line_up_cols Macro
' Macro recorded 09/02/2004 by bc
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Dim myRange As Range
Selection.End(xlDown).Select
Selection.Cut
Selection.Offset(0, -1).Select
ActiveSheet.Paste
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Selecting 2 cells together

Hi Brian

Look in the VBA help for Resize


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Brian" wrote in message ...
I am trying to do the following in a macro:

1. For all occupied cells in one column
2. Jump down to the next occupied cell
3. Select that cell AND the one to the left of it
4. Cut
5. Move the selection one cell to the left.
6. Paste.

The following code does all of that except for step 3. It seems such a
simple thing, but I can't find it in the Google archive.

Can someone help?

Sub Line_up_cols()
'
' Line_up_cols Macro
' Macro recorded 09/02/2004 by bc
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Dim myRange As Range
Selection.End(xlDown).Select
Selection.Cut
Selection.Offset(0, -1).Select
ActiveSheet.Paste
End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Selecting 2 cells together

Ron,,
Thanks for the tip. I have had a look at Resize, and I still haven't got the
answer.

The following code contains 3 attempts to increase the selection from one
cell to two, but none of those attempts works. I am using XL97 - might that
make a difference?


Sub Line_up_cols()
'
' Line_up_cols Macro
' Macro recorded 09/02/2004 by bc
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Dim myRange As Range
Selection.End(xlDown).Select
Set myRange = ActiveCell
myRange.Offset(, -1).Resize(, 1).Select
Selection.Resize(, 1).Select
Selection.Cut
Selection.Offset(0, -1).Resize(, 1).Select
ActiveSheet.Paste
End Sub


"Ron de Bruin" wrote in message
...
Hi Brian

Look in the VBA help for Resize


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Brian" wrote in message

...
I am trying to do the following in a macro:

1. For all occupied cells in one column
2. Jump down to the next occupied cell
3. Select that cell AND the one to the left of it
4. Cut
5. Move the selection one cell to the left.
6. Paste.

The following code does all of that except for step 3. It seems such a
simple thing, but I can't find it in the Google archive.

Can someone help?

Sub Line_up_cols()
'
' Line_up_cols Macro
' Macro recorded 09/02/2004 by bc
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Dim myRange As Range
Selection.End(xlDown).Select
Selection.Cut
Selection.Offset(0, -1).Select
ActiveSheet.Paste
End Sub







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Selecting 2 cells together

Sorry Ron, I wasn't paying attention. I had been assuming that the Resize
command increases the selection by the number of cells specified...

"Brian" wrote in message
...
Ron,,
Thanks for the tip. I have had a look at Resize, and I still haven't got

the
answer.

The following code contains 3 attempts to increase the selection from one
cell to two, but none of those attempts works. I am using XL97 - might

that
make a difference?


Sub Line_up_cols()
'
' Line_up_cols Macro
' Macro recorded 09/02/2004 by bc
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Dim myRange As Range
Selection.End(xlDown).Select
Set myRange = ActiveCell
myRange.Offset(, -1).Resize(, 1).Select
Selection.Resize(, 1).Select
Selection.Cut
Selection.Offset(0, -1).Resize(, 1).Select
ActiveSheet.Paste
End Sub


"Ron de Bruin" wrote in message
...
Hi Brian

Look in the VBA help for Resize


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Brian" wrote in message

...
I am trying to do the following in a macro:

1. For all occupied cells in one column
2. Jump down to the next occupied cell
3. Select that cell AND the one to the left of it
4. Cut
5. Move the selection one cell to the left.
6. Paste.

The following code does all of that except for step 3. It seems such a
simple thing, but I can't find it in the Google archive.

Can someone help?

Sub Line_up_cols()
'
' Line_up_cols Macro
' Macro recorded 09/02/2004 by bc
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Dim myRange As Range
Selection.End(xlDown).Select
Selection.Cut
Selection.Offset(0, -1).Select
ActiveSheet.Paste
End Sub









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
Selecting multiple cells, I can't see the cells highlighted ET Excel Discussion (Misc queries) 1 August 1st 08 03:20 PM
How to change shade of cells when selecting multiple cells abrummet Excel Discussion (Misc queries) 3 September 6th 07 11:42 AM
By selecting cells adjacent to cells tally sheet tom Excel Worksheet Functions 2 September 20th 06 07:09 PM
selecting cells Chris Excel Discussion (Misc queries) 3 July 17th 06 09:58 PM
Selecting Cells BiggyTwo Excel Worksheet Functions 1 May 19th 06 07:54 PM


All times are GMT +1. The time now is 05:01 AM.

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

About Us

"It's about Microsoft Excel"