Variable Range select

diamonddave

New Member
Joined
Jul 23, 2010
Messages
4
Good Morning, I'm working in excel 2003 and am trying for formate the sub total line associated with the sub total function. The row number will be variable, but the column range is fixed from Column B to AP. I can get to the starting point using the following: Note data does not exist in all columns B to AP

Cells.Find(What:="4 Total", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "Sub Total"
ActiveCell.Offset(1, 0).Select

I have tried the following but no luck.

'range(ActiveCell & (LastColumn)).Select
'range(ActiveCell.Offset(-5, 0) & ActiveCell.Offset(35, 0)).Select

being new to programing, I'm note sure if I'm on the right track. any Ideas.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,449
If the Active cell is A10. This will select A5:A45 (41 cells)
Code:
Range(ActiveCell.Offset(-5, 0), ActiveCell.Offset(35, 0)).Select

So will this...
Code:
ActiveCell.Offset(-5, 0).Resize(41, 1).Select


On another note: You don't need to select the cells to do something with them.
This...
Code:
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "Sub Total"
Could be replaced with just this...
Code:
ActiveCell.Offset(0, -1) = "Sub Total"
 
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,163,486
Messages
5,831,970
Members
430,099
Latest member
rdhoy

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