+ Reply to Thread
Results 1 to 10 of 10

Interrupt macro within if statement

  1. #1
    Registered User
    Join Date
    11-23-2007
    Posts
    13

    Interrupt macro within if statement

    I've witten a macro which has an if statement within a loop. It loops thru a range of cells checking whether each cell is null. If the loop encounters a null cell, I want to exit the entire macro. I have the loop and the if coded correctly. I just need the command to end the macro. Thanks

  2. #2
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: Interrupt macro within if statement

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-23-2007
    Posts
    13

    Re: Interrupt macro within if statement

    Thanks Shijesh for the reply. This is actually not working for me. Here is the code:

    Sub afRunMacrosACaACbACADAE()

    Sheets("CUSIPs").Select
    Range("F2").Select
    Do Until ActiveCell = ""
    If ActiveCell = "" Then
    MsgBox " You must enter Issue and Issuer Description on the CUSIPs tab before proceeding."
    Exit Sub
    Else
    ActiveCell.Offset(0, 1).Range("A1").Select
    End If
    Loop
    Application.Run _
    "acbValidateSeriesManualInputValues"
    Application.Run _
    "acMoveSinkingFundsDataSetsToSinkingFundFinalWorksheet"
    Application.Run _
    "adPasteSpecSerialCUSIPsToFINAL"
    Application.Run _
    "aePasteSpecSinkFundDataToFINAL"
    End Sub

    If my validation fails and the loop finds an empty cell, it throws the message, but the macro keeps running and excutes the other macros that follow the loop. Any ideas?

  4. #4
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: Interrupt macro within if statement

    Please wrap your code between [-code] [-/code]

  5. #5
    Registered User
    Join Date
    11-23-2007
    Posts
    13

    Re: Interrupt macro within if statement

    Like this? Sorry, new to using macros and posting on this forum about them.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-23-2007
    Posts
    13

    Re: Interrupt macro within if statement

    Actually, maybe this is right?

    Please Login or Register  to view this content.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Interrupt macro within if statement

    It's hard to help without knowing what your code is supposed to do.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: Interrupt macro within if statement

    Hi,

    Are you getting the Message Box.. when you run code...

    Can you post your workbook with dummy data with the logic...

  9. #9
    Registered User
    Join Date
    11-23-2007
    Posts
    13

    Re: Interrupt macro within if statement

    Actually the issue is with the second macro which also needs an exit sub statement. After making the correction, it works. Thanks for your help.

  10. #10
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Re: Interrupt macro within if statement

    Cheers !!!

    Mark the thread as solved :-)

+ 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