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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,224,918
Messages
6,181,735
Members
453,064
Latest member
robatthe2A

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