Macro using if
Find bottlenecks in your Excel workbooks
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Macro using if

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I have a macro recorded to remove data from the worksheet, paste it elsewhere, clear the original data and let the user strat from scratch again.

    I need to place a code before the main bulk of the macro to stop it running if any of the 15 or so cells is empty. There was a similar question but it referred to one cell only, have tried to manipulate it but keep getting errors.

    Cheers

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    If your range is in, say A1:A15 then the following could be suitable: -

    Dim c As Range
    Dim myRng As Range

    Set myRng = ActiveSheet.Range("A1:A15") ' Change your range here to suit
    For Each c In myRng
    If IsEmpty(c) Then MsgBox "Cell " & c.Address & " is empty. Terminating": Exit Sub
    Next c

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com