selecting mulitple cells

Dummy Excel

Well-known Member
Joined
Sep 21, 2005
Messages
1,004
Office Version
  1. 2019
  2. 2010
  3. 2007
Platform
  1. Windows
Morning All,
I need some code that will select 4 cells, while the columns will be the same, the number of the rows will vary.

the code that I have isnt working like i want it to:

rnum = Selection.Rows.Count
Range(Cells(rnum + 1, 4), Cells(rnum + 1, 7)).Activate

Any help is greatly appreciated
thanks
Samuel
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
You don't really say what you are after... please be more specific.

I'm guessing you may be after something like:

Code:
rnum = Activecell.row 
Range(Cells(rnum, 4), Cells(rnum, 7)).select
or
Code:
rnum = Selection.Rows.Count 
Range(Cells(activecell.row, 4), Cells(activecell.row + rnum, 7)).select

Let us know if either are what you were after.
 
Upvote 0
Sorry for the confussion - I promise to be more specific next time as this forum has help me out alot

I actually added another line to get exactly what I want

Range("d8").End(xlDown).Select
rnum = ActiveCell.Row
Range(Cells(rnum, 4), Cells(rnum, 7)).Select

really appreaciate your time & help
Samuel
 
Upvote 0
That can be done in 1 line:

Code:
Range("D8").End(xlDown).Resize(, 4).Select

however depending on what you are trying to do, it may not be necessary to Select at all. You can work with ranges directly in VBA.
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,854
Members
449,096
Latest member
Erald

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