Excel VBA for highlighting Cells

KurmallyIsmael

New Member
Joined
Apr 7, 2024
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi,
Please help with a VBA code to display the highlighting of cells coler pop up and choosing our color to apply to the cells (by pressing a shortcut like ctrl+h) instead of doing same from the ribbon.

So, for e.g, if I am on Cell A6 and I want to highlight this cell with Purple color, I want to do same just by pressing ctrl+h and then choosing the purple color instead of choosing it from the ribbon.

Grateful for your help...EnjoyExcel :)
 

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
Why use "SendKeys"?

Code:
Sub Get_Colors()
    Application.Dialogs(161).Show
End Sub

Code:
Sub Get_Colors_2()
    Application.Dialogs(xlDialogColorPalette).Show
End Sub
 
Upvote 0
Hi Peter.
Obviously you ended up getting the error also as you mentioned. Do you know why that would be Peter.
I don't get it on mine (excel 2007).
However, after powering up the laptop with excel 2013, it shows the error after the window appears.
Googling did not make me any wiser on the subject.
 
Upvote 0
More to the above. Might be of use to someone else.
I tried with some other DialogDisplays and no error there. I just tried a few but the only one that errors is the ColorPalette (161)
 
Upvote 0
Do you know why that would be Peter.
Not something I know anything about really, so I just did what worked. :eek:
Upon further investigation it looks like this would be it

VBA Code:
Sub Format_Color_2()
  Application.Dialogs(xlDialogPatterns).Show 'Enumeration is 84
End Sub
 
Upvote 0
Solution
Thanks Peter.
That did not error on either machine.
 
Upvote 0
Not something I know anything about really, so I just did what worked. :eek:
Upon further investigation it looks like this would be it

VBA Code:
Sub Format_Color_2()
  Application.Dialogs(xlDialogPatterns).Show 'Enumeration is 84
End Sub
Hi
Thanks...
I think yes we can stick to this option finally.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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