Cycle Formatting

ToWill

New Member
Joined
Feb 27, 2018
Messages
1
Hi,

I have set up a bunch of custom formatting macros and mapped them to different hotkey/short cuts.

I was wondering if anyone knew a way of creating a new macro which would cycle through my different formatting types.

ie: ctrl-shift-up would change the font to blue, if ctrl-shift-up was pressed again it would change to red, and so forth.

Thank you for the help in advance. Any comments/pointers would be grateful.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Welcome to the forum. Here is a simple version of what you are talking about. Running the 'Cycle' subroutine will change the text color of the current selection from red to blue to green.

Code:
Dim Current As Integer


Sub RedText()
Dim r As Range
Set r = Selection
r.Font.Color = vbRed
Current = 1
End Sub


Sub BlueText()
Dim r As Range
Set r = Selection
r.Font.Color = vbBlue
Current = 2
End Sub


Sub GreenText()
Dim r As Range
Set r = Selection
r.Font.Color = vbGreen
Current = 3
End Sub


Sub Cycle()
Dim AR(1 To 3)
AR(1) = "RedText"
AR(2) = "BlueText"
AR(3) = "GreenText"
Current = Current + 1
If Current > UBound(AR) Then Current = 1
Application.Run AR(Current)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,668
Members
448,977
Latest member
moonlight6

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