+ Reply to Thread
Results 1 to 6 of 6

Setting a range

  1. #1
    Forum Contributor
    Join Date
    03-06-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2007, 2010
    Posts
    127

    Setting a range

    My question is why do I get the following error when I'm trying to set the range for a variable. My coding is also below.

    Error message:

    (Run-time error '1004)
    "method range of object _global failed"


    Coding:

    Dim rSortRange As Range
    Set rSortRange = Range("A1:H" & Range("H" & Rows.Count).End(xlUp))


    I'm new to VBA so go easy on me. Thank you.

  2. #2
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Setting a range

    You are missing a parenthesis.

    Please Login or Register  to view this content.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Setting a range

    Hi, BrownBoy,

    try either
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    03-06-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    2007, 2010
    Posts
    127

    Re: Setting a range

    Thanks to both of you for replying so quickly.

    HaHoBe your coding looks to have solved my problem.

    Dim rSortRange As Range
    Set rSortRange = Range("A1:H" & Range("H" & Rows.Count).End(xlUp).Row)



    Quote Originally Posted by HaHoBe View Post
    Hi, BrownBoy,

    try either
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Setting a range

    It is the exact same thing I posted...

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Setting a range

    Hi, GaidenFocus,

    It is the exact same thing I posted...
    I may doubt that.

    Your code
    Please Login or Register  to view this content.
    throws up an exception (Run-Time Error 1004) while my code
    Please Login or Register  to view this content.
    works as well as my other posted code.

    Ciao,
    Holger

+ 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