LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default using Dirty Method

Hi Giselle:

Try:

'=============
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim res As Long
Dim oldVal As Variant
Dim newVal As Variant
Dim sAdd As String

If Target.Count 1 Then Exit Sub

On Error GoTo XIT

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set rng = Intersect(Me.Range("C5:H7"), Target)

If Not rng Is Nothing Then
sAdd = ActiveCell.Address
newVal = rng.Value
Application.Undo
oldVal = rng.Value

With rng
If Not IsEmpty(.Value) Then
res = MsgBox( _
Prompt:="Are you sure you want " & _
"to change the value of " & _
"Cell " & rng.Address(0, 0) & "?", _
Buttons:=vbYesNo)
If res = vbNo Then
.Value = oldVal
Else
.Value = newVal
End If
End If
End With

End If

Me.Range(sAdd).Activate

XIT:
With Application
.EnableEvents = True
.ScreenUpdating = True
End With

End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



"Giselle" wrote in message
...
greetings

I have a range of cells (C5:H7) where users can enter data. But, if they
go back to change a previously entered value, I'd like a msg box to say
"Are you sure you want to change this value?".

I suspect the Dirty Method is involved, but I can't get the syntax to
work.

Any clues?

Cheers, Giselle






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM
Please post this thread a complete correct method, method about te Nast Runsome New Users to Excel 0 February 23rd 08 09:42 PM
intellimouse gone dirty-boy; restore backspace on outer left butt. Terminatrix Excel Discussion (Misc queries) 1 February 15th 05 06:27 AM
Quick n' dirty code to delete rows? simsjr Excel Programming 4 August 30th 04 06:12 PM
How to tell if a range or cell is dirty Carl Rapson Excel Programming 4 February 20th 04 05:09 PM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"