+ Reply to Thread
Results 1 to 7 of 7

Can't set a range in VBA

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Can't set a range in VBA

    I know I'm going to kick myself for this one but I can't figure it out. I've set ranges hundreds of times but this workbook doesn't want to do it.

    On the set range line, I get "application defined or object defined error" I tried removing Sheets("Testing"). and then I get "Method Range of Object Global Failed" I've replaced the range with a simple Range("D5:D8") but no help.
    Please Login or Register  to view this content.
    What am I doing wrong?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Can't set a range in VBA

    Hi,

    Standby to kick...

    You have a semicolon instead of a colon in the address:

    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  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,509

    Re: Can't set a range in VBA

    xlnitwit beat me to the punch/kick.

    Just as a point of interest, it is worthwhile declaring any variable that refers to a row as Long. With Integer you will have issues if you have a large workbook.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Can't set a range in VBA

    This what you are wanting. The was a ; when it needed to be :. Also you can not use count at the end of the split function. Need to use Ubound and +1, because the split function is 0 based


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Can't set a range in VBA

    Arrgh, curse these old eyes! LOL Thanks to all. Special thanks to Mike for fixing the Split functionality.

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Can't set a range in VBA

    No problem thanks for the Rep

  7. #7
    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,509

    Re: Can't set a range in VBA

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 02-24-2017, 02:06 AM
  2. Replies: 4
    Last Post: 07-05-2016, 05:40 AM
  3. Replies: 9
    Last Post: 05-19-2016, 06:48 PM
  4. Replies: 0
    Last Post: 05-18-2016, 04:52 PM
  5. [SOLVED] Help! - Copy Range (Sheet1,A10:F50), Paste Range (Sheet 2,A1:F41), Offset Range & Repeat
    By cjtimmer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2015, 06:27 PM
  6. [SOLVED] Count number of occurances below a range, within a range, and below a range
    By maacmaac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2013, 11:36 PM
  7. send to range, popup box to input what the range should be each time/select range
    By lax2734 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2012, 01:37 AM

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