Cell Status Activates Macro

  • Thread starter Thread starter JAD
  • Start date Start date
J

JAD

The following is a simplified logic statement that I am trying to write in
VB. If someone could interpret it and make it work in VB, I would appreciate
it. What I am trying to do is active/run a macro whenever a specified cell
shows a value of "x". Here is the incomplete statement:

Sub...........Activate_Deactivate
If cell A12="x" then
Activate Macro named Start_Up
If cell A12<>"x" then
Activate Macro named Hide
End Sub
 
I believe the following will work from your example:

Sub_Activate_Deactivate()
If range("A12")="x" then Call Start_Up
If range("A12")<>"x" then Call Hide
End Sub
 
yes but he wants it "whenever" the cell shows the value. i believe
either worksheet_change or worksheet_calculate would be
better.......... but i can't decide which one.
========================
sub worksheet_calculate()

dim ws as worksheet

set ws = activesheet

if ws.range("a12").value = "x" then
call Start_Up
else
call Hide
end if

end sub
===================
:)
susan
 
Since you are basing your criteria in a cell, the Worksheet_Change would
probably work better that using the Activate and Deactivate events. This
would go into the Worksheet code module for the Sheet with Range("A12")
criteria. Right click the sheet tab, click View Code and paste this into the
code window.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target = Range("A12") Then
If LCase(Target) = "x" Then
Start_Up
ElseIf LCase(Target) <> "x" Then
Hide
End If
End If

End Sub
 
forgive me i said "he", could have been "she", should have written OP
for original poster..............
guilty as charged.
:)
susan
 
Back
Top