+ Reply to Thread
Results 1 to 12 of 12

Method 'Range' of object '_Global' failed Error in macro excel 2016

  1. #1
    Registered User
    Join Date
    10-05-2017
    Location
    FRAKFURT
    MS-Off Ver
    2016
    Posts
    16

    Method 'Range' of object '_Global' failed Error in macro excel 2016

    I am new in vba excel coding.I am generating report from sql developer and creating excel files which is attached in first image.
    Capture11.PNG

    Now I want to create macro and rearrange my result in Excel. For this I have created button as shown in previous image and after clicking on button I want to create new sheet and generate result as in second image.
    Capture1.PNG

    I have written below code while recording macro but after clicking on button I'm getting error as

    runtime error 1004 method range of object _global failed
    Below is my vba code:

    Please Login or Register  to view this content.
    Last edited by rade7338; 10-05-2017 at 09:01 AM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    We need to know which line the code fails on - it may be the line containing only Data

    A few comments
    Please Login or Register  to view this content.
    you do not need to select before copying and you can shorthand pasting
    Please Login or Register  to view this content.
    same as:
    Please Login or Register  to view this content.
    Last edited by kev_; 10-05-2017 at 07:02 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    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: Method 'Range' of object '_Global' failed Error in macro excel 2016

    Hi,

    You should please follow the forum rule on cross-posting. This is also posted here- https://stackoverflow.com/questions/...cro-excel-2016
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    10-05-2017
    Location
    FRAKFURT
    MS-Off Ver
    2016
    Posts
    16

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    I have made the changes which you have suggested but getting same error as
    Method 'Range' of object '_Global' failed Error
    in the line
    Range("D" & exportStartRow & ":D" & volumeStartRow - 1).Copy Range("F1")
    . Previously i was getting error in the same line
    Range("D" & exportStartRow & ":D" & volumeStartRow - 1).Select
    .

    Below is the changed code:

    Please Login or Register  to view this content.
    Last edited by rade7338; 10-05-2017 at 07:19 AM.

  5. #5
    Registered User
    Join Date
    10-05-2017
    Location
    FRAKFURT
    MS-Off Ver
    2016
    Posts
    16

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    Hi sorry i dont know i am new to this forum. I will follow the forum rule nowonwards. Thanks.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    Have you cross posted your question anywhere else other than the one xlnitwit mentions in post#5?
    If you have, please post a link to all cross-postings here and in the other forum
    - you must also post a link back to this thread in the thread linked by xlnitwit
    Forum rules prevent me from assisting you further until that has been done
    - please confirm below when all is as it should be
    Thanks

  7. #7
    Registered User
    Join Date
    10-05-2017
    Location
    FRAKFURT
    MS-Off Ver
    2016
    Posts
    16

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    i have posted the question in below forum link and nowhere else. I have not posted it in any other forum.
    https://stackoverflow.com/questions/...ro-excel-2016#

    I have deleted that post from that link.I believe there should not be any problem now. Thanks
    Last edited by rade7338; 10-05-2017 at 07:31 AM.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    Thanks
    It looks as though the value of one of your row variables is the cause of your problem
    Easy way is to use a message box to tell you the value of each variable

    In the 2 lines immediately the line with the error
    Please Login or Register  to view this content.
    Run the code again and hopefully the answer will be in one of the message boxes
    Last edited by kev_; 10-05-2017 at 07:36 AM.

  9. #9
    Registered User
    Join Date
    10-05-2017
    Location
    FRAKFURT
    MS-Off Ver
    2016
    Posts
    16

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    I have tried using below but its returning empty. I belive the volumeStartRow and exportStartRow the value has not been assigned.

    Please Login or Register  to view this content.
    I also checked with immediate window and its returning as :
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    Test the value of variable lastRow in the same way
    Is there more than one sheet in your workbook?
    (Perhaps VBA is looking at wrong sheet)
    Do values "export" and "volume" appear in column D?

  11. #11
    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: Method 'Range' of object '_Global' failed Error in macro excel 2016

    Do you actually have 'export' or 'column' in column D? It doesn't look like it from the pictures.

  12. #12
    Registered User
    Join Date
    10-05-2017
    Location
    FRAKFURT
    MS-Off Ver
    2016
    Posts
    16

    Re: Method 'Range' of object '_Global' failed Error in macro excel 2016

    sorry i have corrected my code little bit. There was column mismatch and now i have tried like this.

    Please Login or Register  to view this content.

    But its generating the result bit not correctly. For record_2 is showing in result 2 times.Before record_4 there should be record_3 column. Its generating the result like below after clicking on button. Also also i want to create new sheet once i click on button and generate the result there.
    But currently its generating the result in the same sheet.
    Capture666.PNG
    Attached Images Attached Images
    Last edited by rade7338; 10-05-2017 at 09:02 AM.

+ 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] 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
  2. Method 'Range' of object '_Global' failed. error in excel-vba
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2013, 04:28 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. MACRO, ERROR 1004, Method 'Range' of object '_Global' failed
    By ssbhardw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-08-2010, 03:49 PM
  6. 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
  7. 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

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