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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,223,958
Messages
6,175,636
Members
452,662
Latest member
Aman1997

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