Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Dec 2003
    Location
    Clinton Twp., Michigan, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel Macro (Excel 2002)

    Is it possible run a macro as a result of an IF function in a cell. For example:

    IF(H5=6,MACRO(A),MACRO([img]/forums/images/smilies/cool.gif[/img])

    I don't know the proper SYNTEX to get MACRO(A) or MACRO([img]/forums/images/smilies/cool.gif[/img] to run. Or if this is at all possible to write this type of function.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Excel Macro (Excel 2002)

    Not from a cell.

    You could put a routine in the worksheetchange event (in VB in the worksheet object.

    <pre>Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Not Intersect(Target, Range("h5")) Is Nothing Then
    Dim vValue
    vValue = Range("H5").Value
    If IsNumeric(vValue) Then
    If vValue = 6 Then
    MacroA
    Exit Sub
    End If
    End If
    MacroB
    End If
    End Sub</pre>


    This would run anytime you change H5. If it is a number and = 6 it would run macroA, anything else in the cell would run macroB

    Steve

Posting Permissions

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