Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost highlighting and font colors; background colors on web pages Jan in Raleigh Excel Discussion (Misc queries) 2 July 31st 07 09:10 PM
Highlighting whole row in this macro [email protected] Excel Programming 1 June 14th 07 07:15 PM
Highlighting blanks via GO TO SPECIAL is not highlighting blank cells - HELP, I'm totally stuck. Jamie Furlong Excel Discussion (Misc queries) 6 August 28th 05 09:27 PM
Macro to rotate data in cells Sue Excel Programming 2 March 28th 05 11:59 PM
How I do I rotate text in an excel cell? The rotate commands is g. MickG Excel Discussion (Misc queries) 3 December 13th 04 08:14 PM


All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"