Select ActiveCell and the Cell next to it

pkew22

New Member
Joined
Aug 30, 2013
Messages
38
I have about 15 columns of data in a spreadsheet. I need to select the data in two columns to format it.
How do I select the ActiveCell and the cell in the next column.?
If D6 was the activecell, Range("D6:E6").select works as it selects the two cells that I want. How do I do it using ActiveCell. The code below does not work.

VBA Code:
ActiveCell.Resize(0, 1).Select
Range(Selection, Selection.End(xlDown)).Select
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
All you need is:
VBA Code:
ActiveCell.Resize(1, 2).Select
 
Upvote 0
Solution
The resize should be 2 not 1 & get rid of the 0 or change it to 1
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Sorry for the followup. How do I select all the data in the two columns if I have blanks? Can I use Selection and LastRow to account for the last rows.

VBA Code:
Dim LastRow As Integer
LastRow = Range("A" & Rows.Count).End(xlUp).Row

ActiveCell.Resize(1, 2).Select
Range(Selection, Selection.End(xlDown)).Select  'Only selects data until the first blank row
 
Upvote 0
How about
VBA Code:
Dim LastRow As Integer
LastRow = Range("A" & Rows.Count).End(xlUp).Row

ActiveCell.Resize(LastRow - ActiveCell.Row + 1, 2).Select
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top