Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    'Dirty' flag, ala Access? (OFF2k/sp3)

    I'm very familiar with VBA/Access, and am only beginning to get into VBA/Excel, so please excuse my "newbiness."

    In Access, when records are modified but not saved, there is a "dirty" flag that is set. Does Excel have something similar for each worksheet? Or do I need to designate some cell as my "dirty" variable, and set it on the Worksheet_Change() event, and clear it on the save() event?

    thanks,
    ..dane

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Dirty' flag, ala Access? (OFF2k/sp3)

    What you are looking for is the (workbook).Saved property.
    Legare Coleman

  3. #3
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Dirty' flag, ala Access? (OFF2k/sp3)

    Excellent -- but is there no way to determine which workSHEETs have been updated?

    ..dane

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Dirty' flag, ala Access? (OFF2k/sp3)

    <<Worksheet_BeforeSave event.>>

    You mean the WorkBook_BeforeSave event.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Dirty' flag, ala Access? (OFF2k/sp3)

    As Hans pointed out, in Excel the only object that has a "saved" property is the workbook. The VBE has more, each VBA component in an Excel file (userform, module and class module) has a saved property.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Dirty' flag, ala Access? (OFF2k/sp3)

    Of course, thanks.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Dirty' flag, ala Access? (OFF2k/sp3)

    The Excel workbook object has a property Saved that is True if the workbook has not been modified since the last time it was saved. The worksheet object does not have such a property, since - unlike records in Access - worksheets do not get saved individually, only the workbook as a whole.

    You can define boolean "Dirty" variables for each worksheet, set them to True in the Worksheet_Change event, and set them to False in the Workbook_BeforeSave event. (Added - had the non-existent Worksheet_BeforeSave event here originally; thanks to Jan Karel Pieterse for pointing out the typo.)

  8. #8
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Dirty' flag, ala Access? (OFF2k/sp3)

    Thanks Hans. I'll likely do just that; add a couple variables and keep track of them manually through event handlers

    thanks!
    ..dane

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •