+ Reply to Thread
Results 1 to 10 of 10

Using "On Error"

  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.

    Please Login or Register  to view this content.
    I was wondering if this part of it is okay:

    Please Login or Register  to view this content.
    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---

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,131

    Re: Using "On Error"

    Please Login or Register  to view this content.


    Why do you need to select the range?

    Regards

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,131

    Re: Using "On Error"

    Sorry, misread

    Please Login or Register  to view this content.

    Regards

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

    Re: Using "On Error"

    Thanks TMShucks,
    Your code worked well to select E3 to E15, but the end result to pick is all of the column that have data to the right of E, which turns out to be all the way to GS. The total is E3:E15,GS3:GS15. I am basically wanting to select data from 1961 Q1 to present Q (which is 2010 Q2). The update is that stupid. My code that I used selects the whole range but only works with the On Error statements.
    I've attached a workbook so you can see roughly what I mean. Sheet1 has the data to find while Sheet2 is where the data is copied to.
    Attached Files Attached Files

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,250

    Re: Using "On Error"

    Does this do the same thing?
    Please Login or Register  to view this content.
    Without needing an On Error ?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,131

    Re: Using "On Error"

    Please Login or Register  to view this content.
    Regards

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

    Re: Using "On Error"

    Both ways worked folks, thank you very much.

    Best Regards,

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,974

    Re: Using "On Error"

    FYI, the reason for your error was that Select does not return a Range object, so you either needed to skip the assignment to the rng variable, or assign and then use
    Please Login or Register  to view this content.
    on a separate line.
    Everyone who confuses correlation and causation ends up dead.

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

    Re: Using "On Error"

    Thanks romperstomper, I don't understand why VBA is that finicky though but it is what it is I guess.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,974

    Re: Using "On Error"

    It's a language and languages have rules. Otherwise they'd be gibberish.

+ Reply to Thread

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