LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default still saving a record to excel even if i press the NO button

try
Sub checkmsgbox()
Dim i As Integer
results = MsgBox("Are you sure you want to add new employee?", vbYesNo)
If results = vbYes Then MsgBox "OK"
End Sub


--
Don Guillett
SalesAid Software

"tweety127" wrote
in message ...

hi....
im working on a project right now and one of its functions is to add
persons on the worksheet....my problem is, how can i stop excel from
adding the person i input if i press Close or No button?...because what
is happening now is that, even if i press the close or no button, still,
that record is added on the worksheet, below is the source code, please
advise:

Sub Button5_Click()

Dim i As Integer
Dim results As Integer
results = MsgBox("Are you sure you want to add new employee?",
vbQuestion, "Add New Employee")

If results = vbOK Then

i = 4
Do While Worksheets("EmployeeDatabase").Range("A" & i) < ""
i = i + 1
Loop
Worksheets("EmployeeDatabase").Unprotect
Worksheets("EmployeeDatabase").Range("A" & i) =
Worksheets("AddNew").Range("G12")
Worksheets("EmployeeDatabase").Range("B" & i) =
Worksheets("AddNew").Range("G16")
Worksheets("EmployeeDatabase").Range("C" & i) =
Worksheets("AddNew").Range("G14")
Worksheets("EmployeeDatabase").Range("D" & i) =
Worksheets("AddNew").Range("G15")
Worksheets("EmployeeDatabase").Range("E" & i) =
Worksheets("AddNew").Range("G13")
Worksheets("EmployeeDatabase").Range("F" & i) =
Worksheets("AddNew").Range("G17")
Sheets("AddNew").Select
Range("G13:G16").Select
Selection.ClearContents
Range("G13").Select
End If
Worksheets("EmployeeDatabase").Protect
End Sub


--
tweety127
------------------------------------------------------------------------
tweety127's Profile:
http://www.excelforum.com/member.php...o&userid=34673
View this thread: http://www.excelforum.com/showthread...hreadid=551394



 
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
find&press button Alex New Users to Excel 1 February 18th 10 03:39 PM
excel close + save by button press. how? tomro1[_6_] Excel Programming 2 June 11th 06 11:45 PM
press button via vb and excel sal21 Excel Programming 0 May 19th 06 01:52 PM
key Press on Forms Button Todd Huttenstine Excel Programming 10 May 21st 04 07:28 PM
Proteting against a button press John Baker Excel Programming 3 October 25th 03 12:14 AM


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