+ Reply to Thread
Results 1 to 11 of 11

Macro to Erase Data

  1. #1
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Macro to Erase Data

    Hi again... I have a workbook with more than 600 worksheets and i'm tring to buid a code that erase the data on specific cells range. I need a code that finds all name sheets that start as "TT", because the day sheets are named as TTJan1, TTJan2, TTJan3, etc, and erase the data in range AE16:ME516 (this code will erase the data in this range in 365 sheets - the range is the same in this 365 sheets). The in the same code, the same thing but for the month sheets which the name of the sheet varies with the month name, so i have 12 more sheets named January, February, March, etc, and the range in this 12 sheets is BW14:BZ44 (The range is the same in this 12 sheets).
    I came across with a code that works, the problem is that i have to write 377 line with every sheet name and range 8which is the same):
    Please Login or Register  to view this content.
    But this code is quite extense... I know there is a way to search for TT and the others 12 sheets (months) as array and then clearcontents on the specific ranges but dont know how to build it...

    EDIT: In TTSep8 the range is the same of the other TT sheets, AE16:ME516. It was a error of copy paste.
    Last edited by Taislin; 11-13-2012 at 03:06 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro to Erase Data

    Whats going on with sept8?

  3. #3
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Macro to Erase Data

    My mistake sorry. Is the same range as the other TT sheets...

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Macro to Erase Data

    You can use this to clear the Ranges with sheets starting with TT.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Macro to Erase Data

    Thank you. And for the months? Cant you make a code where it combines the previous one you gave and adds the instructions for the months sheets too? So i can assign it to a button. I have this code for Transfer Data between workbooks and i think the terms needed are here but dont know how to build it...
    Please Login or Register  to view this content.
    I was thinking in some code maybe like this... its possible?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to Erase Data

    Alternative

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Macro to Erase Data

    Gonna try it... I'll be right back with results!

  8. #8
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Macro to Erase Data

    Perfect. Just stored this macro. Works really well. Thank you very much. Just one more thing. As this macro erase all inputed data in the workbook i would like to add an warning firt before this macro is executed. So if the user presses the button where this macro is assigned, befere he executes it, it runs a previous macro that alerts the user with a message "This procedure will erase all data contained in this workbook. Do you wish to continue?" and the an OK or CANCEL buttons will appear and based on the decision the previous code you gave would be executed or not. Is this possible?

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to Erase Data

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Macro to Erase Data

    Perfect Perfect Perfect. Now its perfect. Thankyou very much!

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to Erase Data

    Please close the thread.

+ 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