ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro button on/off (https://www.excelbanter.com/excel-programming/398908-macro-button-off.html)

Peter

macro button on/off
 
Hello all, I have created a box with a macro assigned to it that will
highlight the cells that have changed from one tab to the other. When I click
on this box the macro runs but I would also like to be able to click it off.
Could someone please help me with this? I have copied the code below that has
been used so far in case that helps. Thanks.

Sub auditt()
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("Original")
Set sh2 = Sheets("Final")
For Each r In sh1.UsedRange
v1 = r.Value
rr = r.Row
cc = r.Column
v2 = sh2.Cells(rr, cc).Value
If v1 < v2 Then
sh2.Cells(rr, cc).Interior.ColorIndex = 36
End If
Next

End Sub



JLGWhiz

macro button on/off
 
What kind of box? Is it just a shape? Is it a UserForm? Is it a control
from the control tool box? A box doesn't do much for me. I need a
definition that fits the VBA conventions.

"Peter" wrote:

Hello all, I have created a box with a macro assigned to it that will
highlight the cells that have changed from one tab to the other. When I click
on this box the macro runs but I would also like to be able to click it off.
Could someone please help me with this? I have copied the code below that has
been used so far in case that helps. Thanks.

Sub auditt()
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("Original")
Set sh2 = Sheets("Final")
For Each r In sh1.UsedRange
v1 = r.Value
rr = r.Row
cc = r.Column
v2 = sh2.Cells(rr, cc).Value
If v1 < v2 Then
sh2.Cells(rr, cc).Interior.ColorIndex = 36
End If
Next

End Sub




All times are GMT +1. The time now is 07:15 AM.

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