selecting mulitple cells

Dummy Excel

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

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

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
994
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,304
Messages
5,600,865
Members
414,409
Latest member
FloordAlex

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