add background color to data in worksheet

daillest319

New Member
Joined
Jan 9, 2012
Messages
43
i trying to write a macro to add Yellow background color to all the data starting from row 2 in a specfic worksheet but the rows of data is always different it coulsbe from row 2 to 50 then the next day from row 2 to 100 etc.


i recorded a macro but it not really helping me.


Code:
Sub Macro2() 
    Range("A2").Select
    Range("A2:O56").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With

End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
hi daillest319
try the following


Sub Macro2()
x=range("o" & rows.count).end(xlup)
Range("A2:O" & x).Select
With Selection.Interior.colorindex=6

End With

End Sub

cheers

kevin
 
Last edited:
Upvote 0
hi daillest319

sorry my mistake
try the following


Sub Macro2()

x = Range("o" & Rows.Count).End(xlUp).Row
Range("A2:O" & x).Interior.ColorIndex = 6


End Sub

cheers

kevin
 
Upvote 0

Forum statistics

Threads
1,224,395
Messages
6,178,344
Members
452,841
Latest member
GenAkaman

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