Warning Message Box when data is changed

jiggaman84

New Member
Joined
Jan 22, 2010
Messages
17
Hi

I want to alert users with a message box containing the following question: "Prior Valuation - Are you sure you want to edit this worksheet?" Ans(Y/N), should the user attempt to edit any cells within a specific range ("C2:AS100") on the worksheet, say Sheet3.

Ideally, it would only pop up the first time the user attempted to make a change to a value within the range. Therefore, if the user say 'Yes', it will not pop up again until the user returns to that worksheet again from another worksheet in the file and attempts to edit a cell value within the C2:AS100 range once more.

I have 300 files that I need this to be applied to, so I plan on implanting the macro from a central source workbook into each workbook using another macro, if that makes any sense.

Thanks in advance!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Paste this into the sheet's code module.

Code:
Dim NewActivate As Boolean

Private Sub Worksheet_Activate()
    NewActivate = True
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If NewActivate = False Then Exit Sub

Dim Rng As Range
Set Rng = Range("C2:AS100")
Dim Ans As Boolean

If Not Intersect(Target, Rng) Is Nothing Then
    Ans = MsgBox("Prior Valuation - Are you sure you want to edit?", vbYesNo)
End If

'do stuff here based on the value of Ans
NewActivate = False

End Sub

You will most likely need to save, close, and reopen your workbook for this to start working.

Let me know if it works for you.
 
Last edited:
Upvote 0
Thanks - this works well!

I now want to apply the code provided to a specific worksheet across 300 identical workbooks. The worksheet name is identical in each of the workbooks ( 'Jun. 30, 2012').

Is there a way to apply the macro and save each workbook? Ideally, I would like to embed the function in each file.

Thanks in advance!
 
Upvote 0
I'm not sure I understand. Are you asking if there's a way to copy-paste this code into 300 workbooks? If yes, then are all the Excel Workbooks currently in the same location?
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,262
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top