ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking for changes. (https://www.excelbanter.com/excel-programming/336803-checking-changes.html)

Neil

Checking for changes.
 
Does anyone know of a way that I can check to see if my workbook has been
altered before it's closed?

I need to do this because I have a workbook where users record serial
numbers allocated to components, but sometime they look up the next number
and then forget to update the workbook with the numbers allocated, the result
being that the next person uses the same numbers again.

I'd like to create some sort of warning box if the workbook has been opened
but no updates have been made.

Not sure if this is possible, but I'd appreciate any ideas anyone lse may have

Thanks

Neil

Jim Thomlinson[_4_]

Checking for changes.
 
Add code similar to this to the thisworkbook module (Right click the Excel
Icon in the upper left corner of the Excel window - Select View Code -
Paste the attached code)

Option Explicit
Public blnChanged As Boolean

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If blnChanged = True Then _
MsgBox "The workbook was changed"
End Sub

Private Sub Workbook_Open()
blnChanged = False
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
blnChanged = True
End Sub

--
HTH...

Jim Thomlinson


"Neil" wrote:

Does anyone know of a way that I can check to see if my workbook has been
altered before it's closed?

I need to do this because I have a workbook where users record serial
numbers allocated to components, but sometime they look up the next number
and then forget to update the workbook with the numbers allocated, the result
being that the next person uses the same numbers again.

I'd like to create some sort of warning box if the workbook has been opened
but no updates have been made.

Not sure if this is possible, but I'd appreciate any ideas anyone lse may have

Thanks

Neil



All times are GMT +1. The time now is 10:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com