+ Reply to Thread
Results 1 to 14 of 14

Delete Content in a row while opening

  1. #1
    Registered User
    Join Date
    06-21-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    24

    Delete Content in a row while opening

    Hi @ all,

    I have a workbook with several worksheets.
    Now I want that the content in row 'AA' of Worksheet '1' gets deleted everytime when I open up the workbook.
    Please be aware that it should not get deleted everytime I open up the Worksheet '1' when I switch thorugh the worksheet...
    It should only get deleted when I open up the whole workbook for the first time.


    Thank you in advance,
    Julian
    Last edited by Julian Schubert; 07-06-2011 at 08:38 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,975

    Re: Delete Content in a row while opening

    AA is a column, not a row ... is that what you meant?

    You'd use a Workbook_Open event to do this:

    Please Login or Register  to view this content.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-21-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete Content in a row while opening

    Yes, of course I mean the column - Sorry!

    Little extra: Is should start deleting the whole column starting in row '2' (there is a heading in row 1...)

    Thank you very much.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,975

    Re: Delete Content in a row while opening

    Maybe then (untested):

    Please Login or Register  to view this content.

    Regards

  5. #5
    Registered User
    Join Date
    06-21-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete Content in a row while opening

    Hello TMShucks,

    Sorry it does not work -

    maybe it is easier if the code should delete all columns 'AA' (starting with AA2) in all worksheets in the workbook...
    but only if I open up the whole workbook for the first time, not while I am working in the workbook and switching from sheet to sheet...

    Thank you

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,975

    Re: Delete Content in a row while opening

    Works for me and does exactly what you have asked for.

    When the workbook is opened, it will clear all cells in column AA from row 2 down.

    Activating and deactivating the sheet will have no effect.

    Regards

  7. #7
    Registered User
    Join Date
    06-21-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete Content in a row while opening

    hmm... okay maybe it does not work because there are other codes and I tried to implement your code in the wrong position...

    this is the complet code and I put yours just on the top.

    FYI: The worksheet is called "ALL", not "Sheet1" anymore


    Please Login or Register  to view this content.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,975

    Re: Delete Content in a row while opening

    It shouldn't make a difference where in the module it is but it *must* be in the workbook class module, not a standard module. Same with the Worksheet_Activate ... that needs to be in the worksheet class module for the sheet being activated, unless you use the Workbook_SheetActivate event which is in the workbook class module.

    The workbook class module is the module that opens when you double click on ThisWorkbook in the VBE.


    Regards

  9. #9
    Registered User
    Join Date
    06-21-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete Content in a row while opening

    sorry - I am a rookie

    May I ask you that you adopt your code in mine so that it works?
    I am not able to do it on my own - embarassing

    Thank you in advance.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,975

    Re: Delete Content in a row while opening

    That doesn't look like Rookie code to me ;-)

    See the attached sample workbook. As I don't speak German, I'm not sure if it works and does what you want ... and I don't have the workbook(s) it tries to access.

    But give this a go.

    Regards
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-21-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete Content in a row while opening

    Thank you for your work.
    It lookes almost very good =)


    Little exception:

    Please Login or Register  to view this content.
    It only deletes the content in shhet "ALL" - and now sometimes I want to change the code that in all worksheets the column AA (starting AA2) gets deleted.

    what do I have to change:

    I tried this code, but it does not work:

    Please Login or Register  to view this content.

    help?
    Thank you


    P.S. "the" code took me forever to make it the way it is... you can not imagine

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,975

    Re: Delete Content in a row while opening

    Please Login or Register  to view this content.

    You need to loop through the worksheets collection, not the workbook.

    Regards

  13. #13
    Registered User
    Join Date
    06-21-2011
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Delete Content in a row while opening

    ok looks perfect - thank you!

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,975

    Re: Delete Content in a row while opening

    You're welcome.

    If this has answered your question, please mark your thread as Solved. See my signature for details or the FAQ.

    Regards

+ 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