+ Reply to Thread
Results 1 to 3 of 3

macro launched when condition is true

  1. #1
    Dariusz Tomon
    Guest

    macro launched when condition is true

    Hi

    I'm wonder if the following sceario is possible:

    I have got macro and I want this macro be launched whenever the cell(1,1) =
    5 (or when this cell is changed)

    Thank you for your proposals.

    Best Regards

    D.Tomon



  2. #2
    Registered User
    Join Date
    05-23-2006
    Posts
    1

    Heres some worksheet code

    Place this code within your WORKSHEET. If the worksheet changes it then checks the change against the code.

    I have defined an coloumn and named the area "arrow", you need to set your area name up and change this code as required

    [email protected]

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    Dim VRange As Range, cell As Range
    Dim Msg As String
    Dim ValidateCode As Variant
    Set VRange = Range("arrow")
    For Each cell In Target

    If Union(cell, VRange).Address = VRange.Address Then

    If cell.Value = "" Then



    ElseIf WorksheetFunction.IsNumber(cell.Value) = True Then
    If cell.Value > 4 Or cell.Value < 3 Then
    MsgBox "Please enter a correct number, either 3 or 4 to display an arrow"
    cell.Value = ""
    cell.Select
    End If
    Else
    MsgBox "Please enter a correct number, either 3 or 4 to display an arrow"
    cell.Value = ""
    cell.Select
    End If

    Exit For
    Exit Sub
    End If
    Next

  3. #3
    Tom Ogilvy
    Guest

    RE: macro launched when condition is true

    If it will hold a formula, then you could use the Calculate event to check -
    but you would have to use a static variable to record the old variable to run
    only when it has changed.

    If it will hold a constant value which will be edited by the user, then you
    could use the Change event

    See Chip Pearson's page on events for an overview
    http://www.cpearson.com/excel/events.htm

    --
    Regards,
    Tom Ogilvy


    "Dariusz Tomon" wrote:

    > Hi
    >
    > I'm wonder if the following sceario is possible:
    >
    > I have got macro and I want this macro be launched whenever the cell(1,1) =
    > 5 (or when this cell is changed)
    >
    > Thank you for your proposals.
    >
    > Best Regards
    >
    > D.Tomon
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1