ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Control Box assigned to multiple spreadsheets (https://www.excelbanter.com/excel-programming/428394-control-box-assigned-multiple-spreadsheets.html)

LUKEMUDGE

Control Box assigned to multiple spreadsheets
 
I have the VB script to change the background color of my cells working but I
would like it to change another cell in a different worksheet. Can anybody
help me out with how to program the reference?

Here is the VB script I'm using to change the colors at the moment

Range("C5").Interior.ColorIndex = -4138 - Range("C5").Interior.ColorIndex

[email protected]

Control Box assigned to multiple spreadsheets
 
Hi
With Worksheets("MyOtherSheet")
.Range("C5").Interior.ColorIndex = -4138 - .Range
("C5").Interior.ColorIndex
End with

note the period in front of both Range.
If you want to do it on all sheets

Dim ws as worksheet
For each ws in Activeworkbook.Worksheets
With ws
.Range("C5").Interior.ColorIndex = -4138 - .Range
("C5").Interior.ColorIndex
End with

regards
Paul


On May 12, 11:26*pm, LUKEMUDGE
wrote:
I have the VB script to change the background color of my cells working but I
would like it to change another cell in a different worksheet. Can anybody
help me out with how to program the reference?

Here is the VB script I'm using to change the colors at the moment

Range("C5").Interior.ColorIndex = -4138 - Range("C5").Interior.ColorIndex




All times are GMT +1. The time now is 10:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com