selecting mulitple cells

Dummy Excel

Well-known Member
Joined
Sep 21, 2005
Messages
1,003
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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

jc113883

Board Regular
Joined
May 29, 2006
Messages
165
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.
 

Dummy Excel

Well-known Member
Joined
Sep 21, 2005
Messages
1,003
Office Version
  1. 2019
  2. 2010
  3. 2007
Platform
  1. Windows
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
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,381
Messages
5,836,922
Members
430,463
Latest member
mikmob

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
Top