• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

M-On M-Off

dparteka

Member
I have a workbook with 10 worksheet tabs labeled 01-10, 11-20, 21-30 and so on up to 91-100. The first macro below places an "M" in cell '01-10'!AM4, the second macro removes the "M". These macros work only in worksheet 01-10, I need the macros to run from all of the worksheets and to not change the active worksheet and cell. Here's an example on how it needs to work... my curser is in cell '41-50'!A1, I run the first macro which places an "M" in the '01-10'!AM4 cell but my worksheet tab and curser never leave cell '41-50'!A1.


Sub MetricOn()

Application.EnableEvents = True

Range("'01-10'!AM4").Select

ActiveCell.FormulaR1C1 = "M"

End Sub


Sub MetricOff()

Application.EnableEvents = False

Range("'01-10'!AM4").Select

ActiveCell.FormulaR1C1 = ""

End Sub
 
Hi ,


Can you try this ?

[pre]
Code:
Sub MetricOn()
Dim sh As Worksheet
Application.EnableEvents = True
For Each sh In Worksheets
sh.Range("AM4").Value = "M"
Next
End Sub

Sub MetricOff()
Dim sh As Worksheet
Application.EnableEvents = False
For Each sh In Worksheets
sh.Range("AM4").Value = ""
Next
End Sub
[/pre]
Narayan
 
Back
Top