+ Reply to Thread
Results 1 to 5 of 5

Macro is deleting sheet, and I would like it to clear contents

  1. #1
    Registered User
    Join Date
    02-06-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Macro is deleting sheet, and I would like it to clear contents

    I am using a borrowed macro to autofilter for me. The macro does exactly what I want it to, with one exception. It deletes and recreates a worksheet page everytime you run it. I think I would like it to just clear contents instead of delete. I am trying to copy the data from the filter to an invoice sheet, but it keeps returning a #REF! error because the sheet is deleted and recreated each time I run the macro. I tried changing the .delete to a .clearcontents, but then it has a problem with creating a sheet with a name that is already being used. I'm rather new at macros and need some help with this. Thanks....The macro is:
    Please Login or Register  to view this content.
    Last edited by royUK; 02-09-2009 at 03:36 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro is deleting sheet, and I would like it to clear contents

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    I will add them this time but read the rules before you post again
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro is deleting sheet, and I would like it to clear contents

    You must have the sheet("MyFilterResult") to copy to
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-06-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Macro is deleting sheet, and I would like it to clear contents

    Sorry about the code tags, this is all pretty new to me. I changed the .delete to .UsedRange.ClearContent, and I get the following error:
    "Cannot rename a sheet to the same name as another sheet, a referenced object library or workbook referenced by visual basic."

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Macro is deleting sheet, and I would like it to clear contents

    I don't think you copied all the relevant sections of Roy's code. You're still trying to create the worksheet again.

    It's a help to say what line the error occurs on.
    Last edited by shg; 02-09-2009 at 06:08 PM.
    Entia non sunt multiplicanda sine necessitate

+ 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