Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Does Excel have a SheetBeforeChange Event?

Thanks Dave this was helpful... I used to code without the message box

"Dave Peterson" wrote:

You may be able to do what you want with worksheet_change.

If you keep track of what the change was, do an application.undo to revert to
before the change, then do what you want, and reapply the changes.

Something like:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myFormula As String
Dim resp As Long

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("a1")) Is Nothing Then Exit Sub

On Error GoTo errHandler:

myFormula = Target.Formula
With Application
.EnableEvents = False
.Undo
resp = MsgBox(Prompt:="did you really mean to change " _
& Target.Address(0, 0) & "?", Buttons:=vbYesNo)
If resp = vbNo Then
'do nothing
Else
Target.Formula = myFormula
End If
End With

errHandler:
Application.EnableEvents = True

End Sub



Fabricio wrote:

I'm looking for a workbook (or worksheet) event that gets triggered before
Excel changes the worksheet. The SheetChange event gets triggered after the
changes have been made to the worksheet--too late for me :)

I'm trying to mimic the response a user gets when she tries to modify a
single cell in an array formula. Excel replies with a message box "You
cannot change part of an array." and does not allow her to make changes.

Thanks in advance,
-Fabricio


--

Dave Peterson

Reply
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
user form-on open event? keydown event? FSt1[_3_] Excel Programming 2 August 5th 04 02:26 PM
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 02:08 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"