rclark88
08-18-2010, 08:50 AM
Hello,
I'm brand new to VBA. I created a macro so I could select a range of cells and change the background color of those cells to yellow.
The problem is that when I select a new cell range and run the macro again, there are now two cell ranges that have a yellow background color.
How would I set this up so that each time I select a new range and run the macro, the previous cell range (with yellow background) is erased. I just want to make sure that I only have one cell range with a yellow background at all times.
Here is the vba macro code:
Sub SetBackGroundColor()
'
' SetBackGroundColor Macro
' Set background color of range.
'
'
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
Any help would be greatly appreciated.
I'm brand new to VBA. I created a macro so I could select a range of cells and change the background color of those cells to yellow.
The problem is that when I select a new cell range and run the macro again, there are now two cell ranges that have a yellow background color.
How would I set this up so that each time I select a new range and run the macro, the previous cell range (with yellow background) is erased. I just want to make sure that I only have one cell range with a yellow background at all times.
Here is the vba macro code:
Sub SetBackGroundColor()
'
' SetBackGroundColor Macro
' Set background color of range.
'
'
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
Any help would be greatly appreciated.