CheekyDevil2386

New Member
Joined
Oct 19, 2020
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
HI experts!

Sorry for the simple question here but I've scoured pages looking for an answer with no luck.

All I'm trying to do is use the below loop code to set all the label forecolor properties to black. The code is contained within a larger With statement if that matters? The height and width work well, just not the forecolor:

It's also in a module, again if that makes any difference, and the labels are all on Sheet1.

VBA Code:
With Sheet1
On Error Resume Next

      For l = 1 To 50
         .Shapes("Label" & l).Height = 19.25
         .Shapes("Label" & l).Width = 102.75
         .Shapes("Label" & l).Forecolor = 0
      Next l

End With

Just can't seem to work out how to reference the labels on Sheet1 to change the text color. Any help is greatly appreciated!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi,

Change the code as below to change the forecolor:

VBA Code:
.Shapes("Label" & l).Fill.ForeColor.RGB = RGB(0, 0, 0)
 
Upvote 0
Solution
Thanks for the reply Saurabhj, unfortunately that hasn't worked. I'll play around with that line as I can see the flow is correct, I may have it in an incorrect area :)

Thank you again for the assistance!
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,048
Latest member
81jamesacct

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