Selecting 2 cells together

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

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
 
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
 
Sorry Ron, I wasn't paying attention. I had been assuming that the Resize
command increases the selection by the number of cells specified...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top