+ Reply to Thread
Results 1 to 10 of 10

Method 'Range' of object '_Global' error

  1. #1
    Registered User
    Join Date
    06-26-2019
    Location
    Utah, US
    MS-Off Ver
    MS Office 16
    Posts
    9

    Method 'Range' of object '_Global' error

    Hey everyone,
    New to the platform.
    My company had someone come in and help write some code for us to automate our reporting. We have this code which allows us to locate duplicate customer ID's, in our data, and find which lead source it came from and then put that lead source into another column so we can then give credit to that appropriate lead source.
    I have been trying to figure out why I keep getting a "Run-time error '1004': Method 'range' of object '_Global' error" message when I try to run my macro code and I haven't been able to figure out the reason for the error.
    When I try to debug the issue it shows me this (below) and I still can't find the problem.
    Just need some direction on possible solutions.
    Cheers
    Last edited by Connor101; 06-26-2019 at 05:15 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Method 'Range' of object '_Global' error

    Welcome to the Forum Connor101!

    Pictures of code are not very useful. In the future please just paste your code directly into your post using [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags. It also helps to show all your code, not just the section where you think the error is.

    Your If statement refers to a named range called "Mandatory". The most likely problem is that there is no named range called "Mandatory". Does the range actually exist? If so, how is it defined? What module is this code in? It would be faster to resolve if you attach your file with private data deleted. The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    06-26-2019
    Location
    Utah, US
    MS-Off Ver
    MS Office 16
    Posts
    9

    Re: Method 'Range' of object '_Global' error

    Thanks for getting back so quickly.
    The "Mandatory" range does exist. Its a column in our data that returns 1s and 0s. As far as what module the code is I'm not sure what you are asking. (Being new to VBA) Could you explain further?
    I have also included the code on this post.

    Please Login or Register  to view this content.
    Again thanks for the help. I really appreciate it
    Last edited by Connor101; 06-26-2019 at 05:44 PM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Method 'Range' of object '_Global' error

    Here is a quick description of VBA modules.

    If the code is in a standard module, like Module1, the Range reference defaults to whatever sheet is active when the code runs.
    If the code is in a worksheet module, like Sheet1, the Range reference defaults to the sheet for that module.

    If the range Mandatory is in a worksheet that is not the default worksheet based on the description above, then it might help to explicitly qualify it using the worksheet it is in:

    Please Login or Register  to view this content.
    Change Sheet1 to the sheet actually containing "Mandatory".

    I'm not 100% sure that will work but that is typically what causes that error in my own code. I would be happy to troubleshoot it if you attach your file, otherwise we'll tackle it this way.

  5. #5
    Registered User
    Join Date
    06-26-2019
    Location
    Utah, US
    MS-Off Ver
    MS Office 16
    Posts
    9

    Re: Method 'Range' of object '_Global' error

    That worked great! It got rid of the error, but now I'm getting an 'Object Required' error.
    Any idea of what I would need to do to resolve this issue?

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Method 'Range' of object '_Global' error

    What module is your code in?
    What sheet contains the range "Mandatory"?
    What sheet is active when this code runs?
    When the "Object Required" error occurs, is it the same code that is highlighted? If not, which code?

  7. #7
    Registered User
    Join Date
    06-26-2019
    Location
    Utah, US
    MS-Off Ver
    MS Office 16
    Posts
    9

    Re: Method 'Range' of object '_Global' error

    It is in a standard module. I decided to move the "Mandatory" range into the ActiveSheet (ws1) which got rid of the '_Global' error.
    When I run the code I make sure to be on the ActiveSheet (ws1) that I want to run the code on.
    To your final question, yes, it is the same bit of code when I get the 'object required' error.
    Thanks for your help again.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Method 'Range' of object '_Global' error

    I assume your code now refers to Worksheets("ws1").Range("Mandatory")?

  9. #9
    Registered User
    Join Date
    06-26-2019
    Location
    Utah, US
    MS-Off Ver
    MS Office 16
    Posts
    9

    Re: Method 'Range' of object '_Global' error

    I does now and it is working!!
    Thank you so much for your help! I really appreciate it!

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Method 'Range' of object '_Global' error

    Phew! Glad it helped. Kind of tough to do this by remote control!

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationiconsmall.jpg below their name.

+ 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. [SOLVED] Method 'Range' of Object'_Global' Failed Error
    By cmurda in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2014, 07:11 PM
  2. [SOLVED] Getting error Method 'Range' of object '_Global' failed
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2013, 04:35 PM
  3. VBA Method 'Range' of object '_Global' failed error
    By RxMiller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2011, 11:06 AM
  4. Error: Method 'Range' of object '_Global' failed
    By awan0126 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2011, 07:25 PM
  5. VBA Method 'Range' of object '_Global' failed error
    By JKCincy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-21-2009, 07:46 PM
  6. Method 'Range' of object' _Global failed error
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-12-2009, 01:52 AM
  7. Error 1004 Method 'Range' of object '_Global' failed
    By bjwade62 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-07-2006, 11:00 AM

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