macro to fill color Yellow

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have tried to write code that where Grand Total appears in Col A, then to fill Color the Cols A:C in the samerow as where Grand total appears


I get an error and the following code is highlighted

Code:
 Range("A" & r & ":C").Interior.Color = 65535


it would be appreciated if someone could assist me


See full code below


Code:
 Sub Colour_GrandTotal()
   Sheets("Pivot Table").Select
Dim lr As Long, r As Long
Dim GTRng As Range

lr = Cells(Rows.Count, "A").End(xlUp).Row
Set GTRng = Columns(1).Find(what:="Grand Total", lookat:=xlWhole)
If Not GTRng Is Nothing Then
    r = GTRng.Row
    If lr >= r Then
      Range("A" & r & ":C").Interior.Color = 65535
      
      
         
         
    End If
End If
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Here is an alternate macro that you might want to consider...
Code:
[table="width: 500"]
[tr]
	[td]Sub ColorGrandTotalsPlusTwoAdditionalCells()
  Columns("A").Replace "Grand Total", "#N/A", xlWhole
  Intersect(Columns("A").SpecialCells(xlConstants, xlErrors).EntireRow, Columns("A:C")).Interior.Color = vbYellow
  Columns("A").Replace "#N/A", "Grand Total", xlWhole
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Hi guys

Thanks for your help, much appreciated
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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