Results 1 to 10 of 10

Using "On Error"

Threaded View

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Question Using "On Error"

    Hi all,
    I have an unknown range of data to select. I came up with this code to do it.

    Sub doCount3()
    Dim rng As Range
    Dim num As Integer
    num = 0
    Range("E3").Select
    Do While ActiveCell.Value <> ""
        ActiveCell.Offset(0, 1).Select
        num = num + 1
    Loop
    Range("E3:E15").Select
    On Error Resume Next
    Set rng = Range("E3:E15").Resize(, num).Select
    On Error GoTo 0
        
    End Sub
    I was wondering if this part of it is okay:

    On Error Resume Next
    Set rng = Range("E3:E15").Resize(, num).Select
    On Error GoTo 0
    Doing this selects the unknown range and readies it for copy but if I do not use On Error, haha, I receive an error message. Is this acceptable by you gurus or is there another way I can do this?
    Last edited by Mordred; 09-01-2010 at 01:21 AM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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