+ Reply to Thread
Results 1 to 9 of 9

How to not get run time error when clearing data with VBA

  1. #1
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    648

    How to not get run time error when clearing data with VBA

    I have a Name Range Called "Body" which references "='Daily Chgs'!$B$3:$BN$45,'Job Ticket'!$f$10:$h$52,'Job Ticket'!$M$10:$M$52,'Job Ticket'!$E$58"
    I also have a macro For clearing the data in that range.
    Please Login or Register  to view this content.
    When I select the macro to run i get a runtime error '1004 reference is not valid

    This used to work when I cleared data only within one sheet ....I am now trying to clear a range of cells on another sheet also and now it wont run.

    What would be the problem?

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: How to not get run time error when clearing data with VBA

    I could be wrong but I don't think VBA is going to work with a named range when that named range references multiple sheets. A way around this could be to directly reference the ranges in code but if you are consistantly changing the cell references of the named range "Body" it will not be efficient for you. If you keep them the same try this:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    648

    Re: How to not get run time error when clearing data with VBA

    I tried that and I am getting runtime error 1004
    Method 'union' of object'_global' failed

    Any thoughts

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to not get run time error when clearing data with VBA

    Does this work?
    Please Login or Register  to view this content.
    If it doesn't does this work?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: How to not get run time error when clearing data with VBA

    Woops I think i spelled Daily as Daly. Double check the sheet names in the code i provided to make sure they match yours.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to not get run time error when clearing data with VBA

    stnkynts

    You can't union ranges that are on different sheets.

  7. #7
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    648

    Re: How to not get run time error when clearing data with VBA

    I did I change the spelling and same error

  8. #8
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    648

    Re: How to not get run time error when clearing data with VBA

    Thanks for the info

  9. #9
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: How to not get run time error when clearing data with VBA

    Ahh thanks Norie

+ 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] run-time error 13 with code - Clearing Contents of cells
    By Chardo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2014, 03:23 AM
  2. [SOLVED] Clearing cells within an Array - Run-time error 13 (Type mismatch)
    By Wobbigone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2013, 01:37 AM
  3. [SOLVED] Clearing a Range of Rows error
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2012, 02:14 PM
  4. [SOLVED] Clearing a Combo Box then trying to submit user form to Workbook gives error messages
    By colvinb in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-21-2012, 02:18 PM
  5. [SOLVED] Clearing an Error
    By lloydgodin in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-23-2012, 06:38 PM

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