change all of the same fill colors in a worksheet

G

Guest

I like to try various fill colors in presentations. Can I change all of the
same fill colors in aworksheet at the same time?
 
M

MartinW

Hi Bob,

It's not very elegant but you can do a global change by
going to Tools>Options>Color Tab then click on a color
square and click modify. This will change any cell using that
tab to whatever you like.

There is probably a way to pre-set this sort of funcionality
with VBA but it would need to be something that is set up
for your individual needs rather than a cure-all that will work
in any situation.

I know virtually nothing about VBA but it might be worth
posting a question in the programming newsgroup.

HTH
Martin
 
B

Bob Phillips

Here is code to follow that route

Sub Macro1()
Dim iOldCI As Long
Dim iNewCI As Long
With ActiveCell.Interior
If .ColorIndex <> xlColorIndexNone Then
iOldCI = .Color
ActiveWorkbook.Colors(.ColorIndex) = GetColor()
End If
End With
End Sub

'-----------------------------­------------------------------­--------------
Function GetColor(Optional Text As Boolean = False) As Long
'-----------------------------­------------------------------­--------------
Dim rngCurr As Range
Dim prev As Worksheet
Dim sh As Worksheet
Set prev = ActiveWorkbook.ActiveSheet
Set rngCurr = Selection
Set sh = ActiveWorkbook.Worksheets.Add
Application.ScreenUpdating = False
With sh
.Range("IV1").Select
Application.Dialogs(xlDialogPatterns).Show
GetColor = ActiveCell.Interior.Color
If GetColor = xlColorIndexAutomatic And Not Text Then
GetColor = xlColorIndexNone
End If
ActiveCell.Interior.ColorIndex = xlColorIndexAutomatic
prev.Activate
rngCurr.Select
Set rngCurr = ActiveSheet.UsedRange
End With
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top