Changing all cell colors when a check box is checked.

UMAKEMESIK

Active Member
Joined
Oct 3, 2005
Messages
378
Hello to all,

i have the code below.
with some fomatting
i am able to change the cell e10 to green
when the check box is checked.

e10 is the first cell the check boxes start and continue on down the column.
i have a checkbox in each cell of column below 10

i tried to drag copy down but when i check any other check box only e10 turns
green as stated in the code.

without having to manually format all the cells individually in the column.

is there a way i can take the code below to apply to all cells in column E below
10?

thanks in advance.

Code:
Sub myCheckBox1()
Application.Run "RedGreen1"
End Sub


Sub RedGreen1()
Application.ScreenUpdating = False

If [E10].Interior.ColorIndex = 2 Then
[E10].Interior.ColorIndex = 10
Exit Sub
End If
If [E10].Interior.ColorIndex = 10 Then
[E10].Interior.ColorIndex = 2
Application.ScreenUpdating = True


End If
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
If you are using Form control checkboxes you can assign this code to all of them
VBA Code:
Sub RedGreen1()
   With Range("E" & ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row)
      If .Interior.ColorIndex = 2 Then
         .Interior.ColorIndex = 10
      Else
         .Interior.ColorIndex = 2
      End If
   End With
End Sub
 
Upvote 0
thanks
tried the code
i am using the form check box.

i drag copied on a test sheet 4 cells down.

when i check the box of any of them
the correct cell truns green

but all the check boxes get checked at the same
time but only the box i checked initially gets the
green color.

i think this has to do with my cell link in format
control as i put in E10

format control --> control --> cell link

i have e10 in here, is this my issue?

any help is appreciated.
 
Upvote 0
Worked great on my test page.
i did not apply any cell link

i drag copied all the way down the sheet
and they all checked and changed color
as they should.

thanks for all of your help.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Hello,

just wondering:

This is a memory hog.
I dragged down to 100 cells and it works great

but the saving and scrolling
and opening is severely hampered.

on 5 rows it works great, but once i start to copy drag down
to many rolls the sheet slows down.

Could it be the Code?
Could it be the two colors in the Code - 2 and 10?

is there a way to construct the code that the first color is blank
and the check color is 10

just looking for ways to minimize the lag.

thanks for your time.
 
Upvote 0
It's more likely to be the number of objects on the sheet, rather then anything else.
 
Upvote 0
Depending on what the checkboxes do, you could possibly replace them with double_click event code
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

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