+ Reply to Thread
Results 1 to 8 of 8

How do I make a Clear button?

  1. #1
    Registered User
    Join Date
    07-03-2007
    MS-Off Ver
    2003
    Posts
    77

    How do I make a Clear button?

    I need to make a clear button that will delete any info within a bunch of different cells within a spreadsheet. Are there any example codes of how I can do this?

    Thanks,

  2. #2
    Forum Contributor corinereyes's Avatar
    Join Date
    12-02-2003
    Location
    Philippines
    MS-Off Ver
    MS Excel 2016
    Posts
    520

    clear infro in cells

    hi, you can use this piece of code.
    Please Login or Register  to view this content.
    Corine

  3. #3
    Registered User
    Join Date
    07-03-2007
    MS-Off Ver
    2003
    Posts
    77
    Sorry, I am not the best with excel programming. I put the code in, but I don't see anything.

    I need a button on the excel page that users can click after filling out and printing the worksheet that will clear out certain cells throughout the worksheet so they can start over without having to manually clear everything out. I have seen this done before but I don't know how to do it. Can someone give me a code to do this?

    Thanks

  4. #4
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    It is going to be very difficult for us to give you a specific answer when you have provided no information to work with.

    Corinareyes has provided a concise example that demonstrates GENERALLY how you can clear cells using macros. Attaching his code to a command button will clear out cells B7, F7, and I7.

    If you need more help, please provide a sample file or specific details.

  5. #5
    Registered User
    Join Date
    07-03-2007
    MS-Off Ver
    2003
    Posts
    77
    I thought I would add that I know how to create a button and link it with a macro, I just don't know how to get a code that will clear selected information within the spreadsheet.

    I also need it to confirm that you wish to do the clearing. For example, you click the button and it says, "Are you sure you wish to clear this spreadsheet?" And you either type Y or N or press a button or something.... then it clears cells A7 E9 G3 H2 for example.

    Thanks,

  6. #6
    Registered User
    Join Date
    07-03-2007
    MS-Off Ver
    2003
    Posts
    77
    Big Bas,

    I know how to insert code into the worksheet, but I don't know how to attach it to a button. I can link a macro to a button, but when I put the code in the worksheet I don't see any macro to attach.

    Also, is there a way for the information to be confirmed before clearing. My previous post contains more info on what I want specifically.

    Thanks

  7. #7
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    Make sure you enter your code into a Module, and not into the sheet code. To do so:
    -Press Alt+F11 to open the VBE
    -In the VBE, go to INSERT-MODULE
    -Copy the code I will provide below.

    Next, add a button from the Forms toolbar
    -In Excel (not the VBE), go to VIEW-TOOLBARS-FORMS
    -Choose the command button icon and add command button to your sheet
    -Right Click the command button and go to Assign Macro.
    -Choose the "Clear_It" macro.

    NOTE: This macro will clear any information in cell A1. Change it to suit:

    Please Login or Register  to view this content.
    Post if you need more help.

  8. #8
    Registered User
    Join Date
    07-03-2007
    MS-Off Ver
    2003
    Posts
    77
    You ROCK! Thanks SO MUCH!

+ 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