VBA and the Color Palette

craigg3

Board Regular
Joined
Dec 23, 2002
Messages
161
Office Version
  1. 2013
Platform
  1. Windows
I am using code to show the color palette, but cant seem to get the color to show up on the a cell, what code do I need to get the color from the palette to the cell.

If I am trying to apply color to range("A1") and I am using this code "Application.Dialogs(xlDialogColorPalette).Show" to show the palette how do I get it to put the color in the cell
Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi Nate,

Nice :)

Tried Your above sample and got an error however
I added following line in the declaration:

Dim CustomColors As Long

and now it running.

Warm regards,
Dennis

Hi Dennis,

I think you got the error because you had Option Explicit at the top of your module (I do the same), I tried using your modification and found it didn't work when I actually choose a custom colour, how with the following declaration below it does:

Dim CustomColors As String

I agree Dennis, this is nice, I'm kinda new to using API in VBA, so this code is a good knowledge widener for me :)
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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