Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Message box to confirm action

I have the following code so that when a cell is selected, it copies all the
cells/formulas from the template worksheet to the active worksheet and
overwrite the target cells.

Now, how can I insert a Pop Up Message to ask Are you sure? and proceed
if Yes, exit if No?

(I just want to make sure if the cell is clicked by accident then the active
worksheet data is not lost.)

------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$K$1" Then
ActiveSheet.Unprotect
ActiveSheet.Range("N3:Q242").Formula =
Sheets("ProgramSummaryTemplate").Range("N3:Q242"). Formula
ActiveSheet.Protect
Range("N3").Select
End If

Cancel = True
End Sub
------------------------
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Message box to confirm action

Hi CRayF,

Something like this would do it:

If MsgBox("Are you sure?", vbYesNo Or vbQuestion _
Or vbDefaultButton2) = vbYes Then
'/ Your Code Here
End If

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


CRayF wrote:
I have the following code so that when a cell is selected, it copies
all the cells/formulas from the template worksheet to the active
worksheet and "overwrite" the target cells.

Now, how can I insert a "Pop Up Message" to ask "Are you sure?" and
proceed if Yes, exit if No?

(I just want to make sure if the cell is clicked by accident then the
active worksheet data is not lost.)

------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$K$1" Then
ActiveSheet.Unprotect
ActiveSheet.Range("N3:Q242").Formula =
Sheets("ProgramSummaryTemplate").Range("N3:Q242"). Formula
ActiveSheet.Protect
Range("N3").Select
End If

Cancel = True
End Sub
------------------------



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Message box to confirm action

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ans
If Target.Address = "$K$1" Then
Ans = Msgbox("Are tyou sure", vbYesNo")
If Ans = vbYes Then
ActiveSheet.Unprotect
ActiveSheet.Range("N3:Q242").Formula =
Sheets("ProgramSummaryTemplate").Range("N3:Q242"). Formula
ActiveSheet.Protect
Range("N3").Select
End If
End If

Cancel = True
End Sub


--
HTH

Bob Phillips

"CRayF" wrote in message
...
I have the following code so that when a cell is selected, it copies all

the
cells/formulas from the template worksheet to the active worksheet and
"overwrite" the target cells.

Now, how can I insert a "Pop Up Message" to ask "Are you sure?" and

proceed
if Yes, exit if No?

(I just want to make sure if the cell is clicked by accident then the

active
worksheet data is not lost.)

------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$K$1" Then
ActiveSheet.Unprotect
ActiveSheet.Range("N3:Q242").Formula =
Sheets("ProgramSummaryTemplate").Range("N3:Q242"). Formula
ActiveSheet.Protect
Range("N3").Select
End If

Cancel = True
End Sub
------------------------



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Message box to confirm action


"CRayF" wrote in message
...
|I have the following code so that when a cell is selected, it copies all
the
| cells/formulas from the template worksheet to the active worksheet and
| ?ooverwrite? the target cells.
|
| Now, how can I insert a ?oPop Up Message? to ask ?oAre you sure??
and proceed
| if Yes, exit if No?
|
| (I just want to make sure if the cell is clicked by accident then the
active
| worksheet data is not lost.)
|
Try this..!

| Private Sub Worksheet_SelectionChange(ByVal Target As Range)

| If Target.Address = "$K$1" Then

If MsgBox("Are you sure?", vbYesNo) = vbYes Then
| ActiveSheet.Unprotect
| ActiveSheet.Range("N3:Q242").Formula =
| Sheets("ProgramSummaryTemplate").Range("N3:Q242"). Formula
| ActiveSheet.Protect
| Range("N3").Select
| End If
End If
| End Sub

HTH
Andrew


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Message box to confirm action

Perfect! Thanks

"Jake Marx" wrote:

Hi CRayF,

Something like this would do it:

If MsgBox("Are you sure?", vbYesNo Or vbQuestion _
Or vbDefaultButton2) = vbYes Then
'/ Your Code Here
End If

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


CRayF wrote:
I have the following code so that when a cell is selected, it copies
all the cells/formulas from the template worksheet to the active
worksheet and "overwrite" the target cells.

Now, how can I insert a "Pop Up Message" to ask "Are you sure?" and
proceed if Yes, exit if No?

(I just want to make sure if the cell is clicked by accident then the
active worksheet data is not lost.)

------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$K$1" Then
ActiveSheet.Unprotect
ActiveSheet.Range("N3:Q242").Formula =
Sheets("ProgramSummaryTemplate").Range("N3:Q242"). Formula
ActiveSheet.Protect
Range("N3").Select
End If

Cancel = True
End Sub
------------------------




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
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
Confirm Delete Message Disable RiosPapa New Users to Excel 2 October 7th 05 09:02 PM
Confirm Autofilter off Chris Excel Programming 2 January 13th 05 07:13 PM
Please confirm the following bug in Excel DennisE Excel Programming 3 December 22nd 03 05:38 PM


All times are GMT +1. The time now is 12:55 PM.

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"