Formatting Subtotal Rows - Resize Range?

SAMCRO2014

Board Regular
Joined
Sep 3, 2015
Messages
160
I am trying to figure out how to resize a range so I can format subtotal lines via a loop. I have no problems with the loop but I am really confused on how the range resize works.

I am searching column F for the word "Total". If that cell contains that word then select columns A to O in that row to be formatted.

Any suggestions?
 

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)
This is what I have so far.

Sub Del_Zero_Totals_Format()


'Set Variables
Dim Ar As Areas
Dim Rng As Range

Dim Previous As Worksheet
Set Previous = ThisWorkbook.Sheets("Previous")

Dim x As Long

'Delete all subtotals with a zero balance and associated data

Set Ar = Range("M2", Range("M" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
For Each Rng In Ar
If Round(Rng.Offset(Rng.Count).Resize(1).Value, 0) = 0 Then Rng.Resize(Rng.Count + 1).EntireRow.Delete
Next Rng

'Define last row of data


Dim LastRow As Long
LastRow = Previous.Cells(Rows.Count, 1).End(xlUp).Row

' Find subtotal rows and change formatting from the bottom to the top if column F contains the word "Total"


For x = LastRow To 2 Step -1

If Cells(x, 6).Value Like "*Total*" Then
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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