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.
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,271
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"
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,385
Messages
5,510,989
Members
408,823
Latest member
TJKnight

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top