+ Reply to Thread
Results 1 to 12 of 12

Autoclear Spreadsheet on Opening

  1. #1
    Registered User
    Join Date
    09-10-2010
    Location
    Redditch, England
    MS-Off Ver
    Excel 2010
    Posts
    35

    Autoclear Spreadsheet on Opening

    Hi

    Hoping someone can help me.

    I have a workbook, which contains 6 spreadsheets.

    One of the spreadsheets is a data capture page called 'MUST BE COMPLETED FIRST!!'. This page then populates a spreadsheet entitled 'JUNE 2013'

    What I would like to know is what is the best way for this workbook to autoclear certain cells within the data capture page only when the user opens the workbook.

    I don't want it to clear any of the cells from the other worksheets. If anyone can help it would be greatly appreciated

    Cheers

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Autoclear Spreadsheet on Opening

    "...to autoclear certain cells within the data capture page only..."

    That would depend on what the certain cells are, which currently would be a guess from us all...
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Autoclear Spreadsheet on Opening

    "...to autoclear certain cells within the data capture page only..."

    That would depend on what the certain cells are, which currently would be a guess from us all...

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Autoclear Spreadsheet on Opening

    Here is a macro-enabled solution. In this example, cells A1 thru A10 are cleared. Include the following event macro in the workbook code area:

    Please Login or Register  to view this content.
    Because it is workbook code, it is very easy to install and use:
    1. right-click the tiny Excel icon just to the left of File on the Menu Bar
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window
    If you save the workbook, the macro will be saved with it.
    If you are using a version of Excel later then 2003, you must save
    the file as .xlsm rather than .xlsx

    To remove the macro:
    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window
    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    To learn more about Event Macros (workbook code), see:

    http://www.mvps.org/dmcritchie/excel/event.htm

    Macros must be enabled for this to work!
    Gary's Student

  5. #5
    Registered User
    Join Date
    09-10-2010
    Location
    Redditch, England
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Autoclear Spreadsheet on Opening

    Oops sorry

    Cells are B2:B4,B7,B8,B17,F6:F28,M2,M6,M20,I7:I9,I15:I17,N14


  6. #6
    Registered User
    Join Date
    09-10-2010
    Location
    Redditch, England
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Autoclear Spreadsheet on Opening

    Quote Originally Posted by Jakobshavn View Post
    Here is a macro-enabled solution. In this example, cells A1 thru A10 are cleared. Include the following event macro in the workbook code area:

    Please Login or Register  to view this content.
    Because it is workbook code, it is very easy to install and use:
    1. right-click the tiny Excel icon just to the left of File on the Menu Bar
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window
    If you save the workbook, the macro will be saved with it.
    If you are using a version of Excel later then 2003, you must save
    the file as .xlsm rather than .xlsx

    To remove the macro:
    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window
    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    To learn more about Event Macros (workbook code), see:

    http://www.mvps.org/dmcritchie/excel/event.htm

    Macros must be enabled for this to work!
    Thanks for that. I have tried it and it doesn't seem to work. Also I am working with Excel 2010 and when I right click the mouse on the small excel icon it doesn't give me the option of opening vba.

    So went into VBA on the developer menu and added the code.

    Could it be that I have a pop up which comes up when they open the workbook as a whole?

    Regards

  7. #7
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Autoclear Spreadsheet on Opening

    Perhaps its in the wrong place. If you can get the VBA window to open, you should see two panes. In the left-hand pane, right the tiny ThisWorkbook icon and select View Code.

    Paste the code in the resulting right hand pane.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-10-2010
    Location
    Redditch, England
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Autoclear Spreadsheet on Opening

    Quote Originally Posted by Jakobshavn View Post
    Perhaps its in the wrong place. If you can get the VBA window to open, you should see two panes. In the left-hand pane, right the tiny ThisWorkbook icon and select View Code.

    Paste the code in the resulting right hand pane.
    Brilliant, that has worked, however it has also cleared the conditional formatting I had in some of the cells. Is there a way round that?

  9. #9
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Autoclear Spreadsheet on Opening

    Try replacing:
    .Clear
    with:
    .ClearContents

  10. #10
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Autoclear Spreadsheet on Opening

    Try replacing:
    .Clear
    with:
    .ClearContents

  11. #11
    Registered User
    Join Date
    09-10-2010
    Location
    Redditch, England
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Autoclear Spreadsheet on Opening

    Awesome, works perfectly thank you so much

  12. #12
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Autoclear Spreadsheet on Opening

    You are very welcome!

+ 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