Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
rotate highlighting colors macro
I need to create a macro that when pressed will cycle through a number
of highlighting colors. So for example when I press the shortcut the first time it will change to yellow, a second time change to red, a third time to grey etc. etc. etc. I'm sure this is relatively basic, but I really need the help. Thanks so much! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
rotate highlighting colors macro
A couple of ideas to play with. Right click sheet tabview codeinsert
allplay. Public num'top line of sheet module Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Target.Interior.ColorIndex = num num = num + 1 End Sub 'Private Sub Worksheet_SelectionChange(ByVal Target As Range) ''num = 1 'Select Case num 'Case 1: x = 10 'Case 2: x = 4 'Case 3: x = 6 'Case Else 'End Select 'Target.Interior.ColorIndex = x 'num = num + 1 'End Sub Sub startover() num = 1 End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software wrote in message ... I need to create a macro that when pressed will cycle through a number of highlighting colors. So for example when I press the shortcut the first time it will change to yellow, a second time change to red, a third time to grey etc. etc. etc. I'm sure this is relatively basic, but I really need the help. Thanks so much! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
rotate highlighting colors macro
Something like this should do what you want...
Dim NewColor As Long Static LastColor As Long Do NewColor = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd) Loop Until NewColor < LastColor LastColor = NewColor Range("D4:F10").Cells.Interior.Color = NewColor Just so you know what is going on, the loop is there to make sure the last color used is not repeated. Set the range of cells whose color you want to change in the Range statement at the bottom of the code. Rick wrote in message ... I need to create a macro that when pressed will cycle through a number of highlighting colors. So for example when I press the shortcut the first time it will change to yellow, a second time change to red, a third time to grey etc. etc. etc. I'm sure this is relatively basic, but I really need the help. Thanks so much! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Lost highlighting and font colors; background colors on web pages | Excel Discussion (Misc queries) | |||
Highlighting whole row in this macro | Excel Programming | |||
Highlighting blanks via GO TO SPECIAL is not highlighting blank cells - HELP, I'm totally stuck. | Excel Discussion (Misc queries) | |||
Macro to rotate data in cells | Excel Programming | |||
How I do I rotate text in an excel cell? The rotate commands is g. | Excel Discussion (Misc queries) |