ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a more efficient way to do this? (https://www.excelbanter.com/excel-programming/341125-there-more-efficient-way-do.html)

Steve Roberts

Is there a more efficient way to do this?
 
I have a sheet with 28 checkbox controls on it. When a Highlight Changes
Button is selected a Public variable is set to true and any changes made to
the sheet are highlighted. I have a functional bit of code but am wondering
if there is a more efficient way to check for changes in each of the 28
checkboxes without having to enter this code 28 times.

Here is the functional code:

Private Sub CheckBox1_Change()
If blTrackChanges = True Then 'Check Public Variable blTrackChanges
If true then enable Highlight Modifications
CheckBox1.BackColor = &H80C0FF
End If
End Sub

Any ideas would be appreciated.

Thanks

Steve



Bob Phillips[_6_]

Is there a more efficient way to do this?
 
Put the code in a separate parameter driven macro, like so

Private Sub CheckBox1_Change()
Call CheckAny(CheckBox1)
End Sub

Private Sub CheckAny(cb As MSForms.CheckBox)
If blTrackChanges = True Then 'Check Public Variable blTrackChanges
'If true then enable Highlight Modifications
cb.BackColor = &H80C0FF
End If
End Sub


--
HTH

Bob Phillips

"Steve Roberts" wrote in message
...
I have a sheet with 28 checkbox controls on it. When a Highlight Changes
Button is selected a Public variable is set to true and any changes made

to
the sheet are highlighted. I have a functional bit of code but am

wondering
if there is a more efficient way to check for changes in each of the 28
checkboxes without having to enter this code 28 times.

Here is the functional code:

Private Sub CheckBox1_Change()
If blTrackChanges = True Then 'Check Public Variable blTrackChanges
If true then enable Highlight Modifications
CheckBox1.BackColor = &H80C0FF
End If
End Sub

Any ideas would be appreciated.

Thanks

Steve






All times are GMT +1. The time now is 04:24 PM.

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