Writing correct syntax for a macro button command

stonecoldmike

New Member
Joined
Sep 14, 2024
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I'm trying to put together a spreadsheet using a table of data and creating buttons that will change a row of cells to a particular color, namely that of the button itself. When I type the comma d in I'm getting a syntax error becasue when I click the button, the range of cells don't change. I'm typing in as follows:
.Color = CH606
and it isn't working. Should the text turn green?
 

Attachments

  • 1000003332.jpg
    1000003332.jpg
    108.9 KB · Views: 3

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I'm typing in as follows:
.Color = CH606
That is not what your screenshot shows. It shows
VBA Code:
.Color = &H60&
Also it has the color hard-coded. If you want to use the color of the button, the code should use that color, in case you change the button color later.
When I type the comma d in
No idea what you mean by that.
Should the text turn green?
Nor that. Which text do you mean?

When sharing code, please copy the code directly from your code editor and paste it into your post. A screenshot of the code is not very useful, and your screenshot is pretty low resolution making it hard to read. Paste in the code, select it, then click the VBA button in the edit controls to apply code tags to preserve formatting.
 
Upvote 0

Forum statistics

Threads
1,221,527
Messages
6,160,342
Members
451,638
Latest member
MyFlower

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