View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default worksheet_change help

in the worksheet, right click on the tab you want this associated with
and choose "view code".
then cut & paste your macro there, using this language at the top
instead of Sub R4R5Reset().

Private Sub Worksheet_Change(ByVal Target As Range)

i believe that if you don't specify a target, it should work anytime
anything is changed anywhere on the sheet. i could be wrong about
that, so there may be an additional fixing you'll need.

hope it gets you started
susan


On Jun 25, 9:01*am, Mike B. wrote:
I have a macro that I want to apply to a specific worksheet. So that when I
go to the worksheet and change any cell, the sheet will automatically call
the macro.

I have R4R5Reset already in a module and know I have to go to the specific
sheet to do some private sub worksheet_????. I just don't know how to get to
call it everytime I change any cell on the sheet.

Option Explicit

Sub R4R5Reset()

'Define Variables
Dim InPutOne, InPutTwo, InPutThree As Double
Dim OutPutOne, OutPutTwo As Range
Dim Input3 As Range
Dim first As Boolean
Dim last As Boolean

'Set Variables
InPutOne = Range("AA12").Value
InPutTwo = Range("C11").Value
Set OutPutOne = Range("Y6")
Set OutPutTwo = Range("X23")
Set Input3 = Range("S16")

'Booleans
first = OutPutOne.Value = "UNLATCH"
last = OutPutTwo.Value = "LATCH"

* 'Different scenarios
* * If InPutOne = 0 And InPutTwo = 0 And first Then
* * * InPutThree = 0
* * ElseIf InPutOne = 0 And InPutTwo = 1 Then
* * * InPutThree = 1
* * ElseIf InPutOne = 1 And InPutTwo = 1 Then
* * * InPutThree = 1
* * ElseIf InPutOne = 0 And InPutTwo = 0 And first = False Then
* * * InPutThree = 1
* * * first = True
* * ElseIf InPutOne = 1 And InPutTwo = 0 Then
* * * InPutThree = 0
* * End If

* *'Results
* * If InPutThree = 0 Then
* * * OutPutOne.Value = "UNLATCH"
* * * OutPutTwo.Value = ""
* * * Input3.Value = 0
* * ElseIf InPutThree = 1 Then
* * * OutPutTwo.Value = "LATCH"
* * * OutPutOne.Value = ""
* * * Input3.Value = 1
* * End If
End Sub