Run VBA from Excel 2010 Ribbon

I've tried different examples of how to move my VBA buttons to the ribbon, but either the text is marked in red (aka error) or the examples involve doing some xml transformations (never done before, so they don't make sense).

All I want to do is move my text coloring buttons to my own ribbon. When the user clicks on the button icon (inside the ribbon), VBA coding is performed.

enter image description here

As you can see above, there is currently a Text-Green button on the ribbon ... when the user clicks on it .. it creates an empty command button for the user to create new command buttons. It is clear that I do not want to.

Any suggestions?

My blue and red button coding (simple coding):

Private Sub Color_Blue_Click()
    Selection.Font.Color = RGB(83, 141, 213)
End Sub

Private Sub Color_Red_Click()
    Selection.Font.Color = RGB(255, 0, 0)
End Sub

      

enter image description here

I tried the link:

http://www.rondebruin.nl/win/section2.htm

+3


source to share


1 answer


Wow, I guess this was a simple afterall fix:

I went to:

Developer Tab/Record Macro

Named macro as TextGreen

.... clicked Ok

and once it was saved I clickedStop Recording

Returned to the tab Developer/Code

and clickedMacros



Then I clicked Edit

and typed my code there:

Sub TextGreen()

  Selection.Font.Color = RGB(0, 176, 80)

End Sub

      

enter image description here

To save the feed, I did:

Right click Ribbon/Customize Ribbon

... Selected Macros

from dropdown ... save the group under the Ribbon tab and add it.

+1


source







All Articles