+ Reply to Thread
Results 1 to 11 of 11

Method range of object failed

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Method range of object failed

    I can't see the problem with this formula but I get the following error message.
    Method range of object global failed


    Range("AW3:AW" & SecondLastRow - 1) = "=VLOOKUP(AT3,Range(""J3:J"" & LastRow - 1),8,FALSE)"
    Thanks in advance

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Method range of object failed

    Try Range("AW3:AW" & SecondLastRow - 1).value
    Elegant Simplicity............. Not Always

  3. #3
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: Method range of object failed

    I found the problem. I had not used Dim for SecondLastRow. I have used the following code to select two entire columns:
    Columns("S:S", "AW:AW").Select
    , but get an error message. Can someone correct this please?

  4. #4
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: Method range of object failed

    I am now getting this formula in the cell range?
    =VLOOKUP(AT3,Range("J3:J" & LastRow - 1),8,FALSE)
    Thanks in advance

  5. #5
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: Method range of object failed

    The formula reflects #NAME? in the cells. It is not selecting my LastRow range?
    Thanks in advance

  6. #6
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: Method range of object failed

    I changed the code as follows but get the following error: [Object variable or With block Variable not set]:
    LookupRange = Range("J3:J" & LastRow - 1)
    Range("AW3:AW" & SecondLastRow - 1).Value = "=VLOOKUP(AT3,LookupRange,8,FALSE)"
    Thanks in advance

  7. #7
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: Method range of object failed

    This is the code I am using but the formula in the cell uses [LookupRange] instead of the range J3:J2565?

    Dim LookupRange As Range
    Set LookupRange = Range("J3:J" & LastRow - 1)
    Range("AW3:AW" & SecondLastRow - 1).Value = "=VLOOKUP(AT3,LookupRange,8,FALSE)"
    Thanks in advance

+ 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