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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
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,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

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