Highlight Row Yellow

Papi

Well-known Member
Joined
May 22, 2007
Messages
1,592
I'm using the folowing code in a workbook that converts Range("A1:T1") to highlight that range with bright yellow.

Option Explicit

Dim Rng As Range

Sub HighlightYellow()

Range("A" & ActiveCell.Row).Select

Set Rng = ActiveCell.Range("A1:T1")

With Rng.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With

Application.OnTime Now + TimeValue("00:00:10"), "RemoveHighlight"

End Sub

Sub RemoveHighlight()

With Rng.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With

End Sub

I would like to use this in the same book with other column lengths, some more columns, some less. Is it possble to have it find the last columne rather than hard copy a specified column. As well, rather than have the cursor return to Column "A" is is posibble to have the cursor remain where it was a the time it started the highlighting. And one last question, is it possible to shutoff the macro to go and hightlight another row?

Thanks,
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
try this macro test

Code:
Sub tests()
Range(Range("A1"), Cells(1, Columns.Count).End(xlToLeft)).Interior.ColorIndex = 6
End Sub


Code:
Sub undo()
Range(Range("A1"), Cells(1, Columns.Count).End(xlToLeft)).Interior.ColorIndex = xlNone
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,787
Members
452,942
Latest member
VijayNewtoExcel

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