• 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.

Macro controled by Cell content

Hello,
I am wondering if it is possible if I can control a macro with the content within a cell.
I have a shop calendar which (using a macro) I want to roll ahead 1 period. I have an IF( statement in a cell which will read as "Locked" when I roll the calendar forward more than one period from the presant day. Is there a way in which I can control the macro to not roll forward a second time either through this cell reference or by any other means?
 
Certainly. Here's an example of how you could set it up:
Code:
Sub ExampleCode()
Dim myRange As Range

Set myRange = Worksheets("Sheet1").Range("A2")

If myRange.Value = "Locked" Then
    MsgBox "You're already locked out!", vbOKOnly, "Locked"
    'dont do anything else?
Else
    'do your regular code
End If
End Sub
 
Hi, Jamie Wagler!
You seem to be a bit lost, so why don't you elaborate a bit more and explain it with a specific example?
Consider uploading a sample file (including manual examples of desired output if applicable), it'd be very useful for those who read this and might be able to help you. Thank you.
Regards!
 
@Luke M

I'm not sure I follow, is that done within the conditional formatting or is it apart of the macro itself?
Not conditional formatting, it was adding to your existing code. The comment "do your regular code" is where you would put your existing stuff. If statement checks first if we should run, and if locked, don't do anything.
 
Back
Top