+ Reply to Thread
Results 1 to 12 of 12

Auto Clear Range when file is closed and reopened again

  1. #1
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Auto Clear Range when file is closed and reopened again

    Hey guys, I need a small help,

    I want to clear Range A2:F2 automatically when the excel file is closed and reopened.
    I am using Rangr A1:F1 to filter cells.
    So i want it to clear the range A2:F2 automatically when file is closed.

    Currently I have this code to filter cells:
    Please Login or Register  to view this content.
    The 2nd part of the code auto clears range A2:F2 when i change my page.

    I have attached my code in Post 3. Please do have a look
    Last edited by anilpatni1234; 04-21-2019 at 06:46 AM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Auto Clear Range when file is closed and reopened again

    In your file in sheet "PRODUCT" in range "A2:F2" there is no data ...!
    Is it the right range ???

    Else in a module put


    Please Login or Register  to view this content.
    Last edited by PCI; 04-21-2019 at 05:23 AM.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: Auto Clear Range when file is closed and reopened again

    Hey PCI,
    thank you so much for your reply.
    i have updated my file. Please do have a look.
    In cell "A2" i have data "2" written on it.

    Now what I want is that if i close this file , and reopen this file, then I want it to auto clear range A2:F2.
    Basically i want to clear the range A2:F2 everytime i open the file
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Auto Clear Range when file is closed and reopened again

    Basically i want to clear the range A2:F2 everytime i open the file

    Yes this the job of Sub Auto_Open()
    Attached Files Attached Files
    Last edited by PCI; 04-21-2019 at 07:04 AM.

  5. #5
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: Auto Clear Range when file is closed and reopened again

    Hey PCI,'

    If i type "2" in cell "A2", then it filters the sheet , column "F" with "2" and hance shows the filterted results.

    the code which you mentioned , clears the range whenever I open the file again but it does not show the other data in the sheet. It stays in filtered mode. So i need to press "backspace" button in my keyboard in cell A2 to show the other data .

    How can we fix it? i want the code to clear the cell contents and ulfilter it also.

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Auto Clear Range when file is closed and reopened again

    See how nextcode works ...!
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: Auto Clear Range when file is closed and reopened again

    Hey PCI,
    it is not working . I tried it. I have attached workbook . Please do have a look if i did it right.
    I have uploaded my file .

    Thank you
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Auto Clear Range when file is closed and reopened again

    Okay, let's do it more simply
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: Auto Clear Range when file is closed and reopened again

    Hey PCI,
    the code works perfectly.
    However if there is no data in range A2:G2 and i close the file. And open the file again then i get this error : (i have uploaded the image)

    Please do have a look
    Attached Images Attached Images

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Auto Clear Range when file is closed and reopened again

    Here again
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    08-18-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    490

    Re: Auto Clear Range when file is closed and reopened again

    Hey PCI,

    the code works perfectly now.
    thank you for all your valubale time and help.
    It means a lot.
    Thank you

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Auto Clear Range when file is closed and reopened again

    You're welcome
    Happy Easter

+ 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. External references changed when sheet is closed and reopened
    By crct in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-05-2018, 06:37 AM
  2. How to have checkbox stay True when userform is closed and reopened
    By Gal403 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-02-2014, 12:57 PM
  3. Replies: 0
    Last Post: 01-18-2014, 02:02 PM
  4. [SOLVED] Need to auto sort column when file is saved/closed
    By jingles9 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-19-2013, 01:44 PM
  5. Listbox items clear after worksheet is closed then reopened
    By skins0gr in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 05-24-2013, 12:02 PM
  6. Replies: 2
    Last Post: 02-20-2013, 08:27 AM
  7. [SOLVED] Auto Data Input from a Closed File
    By rvalasho in forum Excel General
    Replies: 1
    Last Post: 04-20-2005, 01:06 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