+ Reply to Thread
Results 1 to 2 of 2

Allow code to continue regardless

  1. #1
    Pat
    Guest

    Allow code to continue regardless

    The following code will return an error if there is nothing to return:

    With ActiveSheet
    With ActiveSheet
    Set rng1 = Nothing
    Set rng1C = Nothing
    Set rng1F = Nothing
    On Error Resume Next
    Set rng1C = .Range("Q74:Q1000"). _
    SpecialCells(xlConstants, xlNumbers)
    Set rng1F = .Range("Q74:Q1000"). _
    SpecialCells(xlFormulas, xlNumbers)
    On Error GoTo 0
    If rng1C Is Nothing Then
    Set rng1 = rng1F
    Else
    If rng1F Is Nothing Then
    Set rng1 = rng1C
    Else
    Set rng1 = Union(rng1F, rng1C)
    End If
    End If
    If rng1 Is Nothing Then
    MsgBox "No quantities found"
    Exit Sub
    End If
    End With


    I need the code to continue executing and ignore the nothing to return
    element.
    Thank you if you can help.
    Pat

    P.S. I have only included part of the code which I feel relevant, if more
    clarity is needs I can provide it.



  2. #2
    Don Guillett
    Guest

    Re: Allow code to continue regardless

    try
    on error resume next

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Pat" <[email protected]> wrote in message
    news:[email protected]...
    > The following code will return an error if there is nothing to return:
    >
    > With ActiveSheet
    > With ActiveSheet
    > Set rng1 = Nothing
    > Set rng1C = Nothing
    > Set rng1F = Nothing
    > On Error Resume Next
    > Set rng1C = .Range("Q74:Q1000"). _
    > SpecialCells(xlConstants, xlNumbers)
    > Set rng1F = .Range("Q74:Q1000"). _
    > SpecialCells(xlFormulas, xlNumbers)
    > On Error GoTo 0
    > If rng1C Is Nothing Then
    > Set rng1 = rng1F
    > Else
    > If rng1F Is Nothing Then
    > Set rng1 = rng1C
    > Else
    > Set rng1 = Union(rng1F, rng1C)
    > End If
    > End If
    > If rng1 Is Nothing Then
    > MsgBox "No quantities found"
    > Exit Sub
    > End If
    > End With
    >
    >
    > I need the code to continue executing and ignore the nothing to return
    > element.
    > Thank you if you can help.
    > Pat
    >
    > P.S. I have only included part of the code which I feel relevant, if more
    > clarity is needs I can provide it.
    >
    >




+ 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