Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default msgbox answer

Hello again!

How do you make things happen on the msgbox event? if someone says yes,
cancel, retry or any similar response nothing happens, the code just
carries on as normal!

I was rather hoping that the results of said answers might be preset!
so i assume that i need to set the answer?

I have tried something like "if msgbox = vbyes then dosomething elseif
etc etc" but having problems getting that to work so i assume thats not
the way to go about it.

Any ideas?

Duncan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default msgbox answer

Hi

Dim Response as Variant

Response = Msgbox(Text, vbYesNoCancel, Titletext)

If Response = vbYes then
do something
end if

regards
Paul

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default msgbox answer

Hi Duncan.

Try something like:
'=============
Public Sub Tester001()
Dim res As Long

res = MsgBox(Prompt:="Do you want to ...", _
Buttons:=vbYesNoCancel)

If res = vbYes Then
'do something, e.g.:
MsgBox "You said yes"
ElseIf res = vbNo Then
' do domething else, e.g:
MsgBox "You said no"
Else
MsgBox "You cancelled"
End If

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

---
Regards,
Norman



"Duncan" wrote in message
oups.com...
Hello again!

How do you make things happen on the msgbox event? if someone says yes,
cancel, retry or any similar response nothing happens, the code just
carries on as normal!

I was rather hoping that the results of said answers might be preset!
so i assume that i need to set the answer?

I have tried something like "if msgbox = vbyes then dosomething elseif
etc etc" but having problems getting that to work so i assume thats not
the way to go about it.

Any ideas?

Duncan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default msgbox answer

Yep, Brilliant. This works a treat. The only thing im slightly unsure
about now is how to get it to go back to putting in the search info
upon vbno. for some reason it shows me another msgbox that is blank?!
(ill paste my whole sub in and perhaps you might spot something, ive
probly gone arse-about-face!)

Private Sub submitint_Click()

'sets up error handler
On Error GoTo errorhandler
'disable screeen flickering
Application.ScreenUpdating = False
'set up range to search
Range("A1:A65000").Select

'sets the find option to match the userform-textbox to the range
Selection.Find(What:=Interiminput.regint.Value, LookIn:=xlValues,
SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

'Message Box tells user what the name and reg is
MsgBox "Is this the correct Employer? " & ActiveCell.Offset(0, 2),
vbYesNo, " Confirm "
Dim Response As Variant
Response = MsgBox(Text, vbYesNo, Titletext)
If Response = vbYes Then
' submit the data to the relevant cells (working)
ActiveCell.Offset(0, 22).Range("A1").Select
ActiveCell.Value = (claimnoint)
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = (daysint)
' clear the cells for next entry
regint.Value = ""
claimnoint.Value = ""
daysint.Value = ""
MsgBox "Submitted", vbOKOnly, " Status "
Cells(1, 1).Select
Exit Sub
ElseIf Response = vbNo Then
Exit Sub
End If

'show message box if match not found
errorhandler:
MsgBox "Reg not found! Please retry", vbOKOnly, "Registration not
found"
regint.Value = ""
regint.SetFocus

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default msgbox answer

Yep, Brilliant. This works a treat. The only thing im slightly unsure
about now is how to get it to go back to putting in the search info
upon vbno. for some reason it shows me another msgbox that is blank?!
(ill paste my whole sub in and perhaps you might spot something, ive
probly gone arse-about-face!)

Private Sub submitint_Click()

'sets up error handler
On Error GoTo errorhandler
'disable screeen flickering
Application.ScreenUpdating = False
'set up range to search
Range("A1:A65000").Select

'sets the find option to match the userform-textbox to the range
Selection.Find(What:=Interiminput.regint.Value, LookIn:=xlValues,
SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

'Message Box tells user what the name and reg is
MsgBox "Is this the correct Employer? " & ActiveCell.Offset(0, 2),
vbYesNo, " Confirm "
Dim Response As Variant
Response = MsgBox(Text, vbYesNo, Titletext)
If Response = vbYes Then
' submit the data to the relevant cells (working)
ActiveCell.Offset(0, 22).Range("A1").Select
ActiveCell.Value = (claimnoint)
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = (daysint)
' clear the cells for next entry
regint.Value = ""
claimnoint.Value = ""
daysint.Value = ""
MsgBox "Submitted", vbOKOnly, " Status "
Cells(1, 1).Select
Exit Sub
ElseIf Response = vbNo Then
Exit Sub
End If

'show message box if match not found
errorhandler:
MsgBox "Reg not found! Please retry", vbOKOnly, "Registration not
found"
regint.Value = ""
regint.SetFocus

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default msgbox answer

Private Sub submitint_Click()
Dim txt as String
Dim TitleText as String
'sets up error handler
On Error GoTo errorhandler
'disable screeen flickering
Application.ScreenUpdating = False
'set up range to search
Range("A1:A65000").Select

'sets the find option to match the userform-textbox to the range
Selection.Find(What:=Interiminput.regint.Value, LookIn:=xlValues,
SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

'Message Box tells user what the name and reg is
Txt = "Is this the correct Employer? " & ActiveCell.Offset(0, 2),
TitleText = " Confirm "
Dim Response As Variant
Response = MsgBox(Txt, vbYesNo, Titletext)
If Response = vbYes Then
' submit the data to the relevant cells (working)
ActiveCell.Offset(0, 22).Range("A1").Select
ActiveCell.Value = (claimnoint)
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = (daysint)
' clear the cells for next entry
regint.Value = ""
claimnoint.Value = ""
daysint.Value = ""
MsgBox "Submitted", vbOKOnly, " Status "
Cells(1, 1).Select
Exit Sub
ElseIf Response = vbNo Then
Interiminput.regint.Value = ""
Exit Sub
End If

'show message box if match not found
errorhandler:
MsgBox "Reg not found! Please retry", vbOKOnly, "Registration not
found"
regint.Value = ""
regint.SetFocus

End Sub

--
Regards,
Tom Ogilvy


"Duncan" wrote in message
oups.com...
Yep, Brilliant. This works a treat. The only thing im slightly unsure
about now is how to get it to go back to putting in the search info
upon vbno. for some reason it shows me another msgbox that is blank?!
(ill paste my whole sub in and perhaps you might spot something, ive
probly gone arse-about-face!)

Private Sub submitint_Click()

'sets up error handler
On Error GoTo errorhandler
'disable screeen flickering
Application.ScreenUpdating = False
'set up range to search
Range("A1:A65000").Select

'sets the find option to match the userform-textbox to the range
Selection.Find(What:=Interiminput.regint.Value, LookIn:=xlValues,
SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

'Message Box tells user what the name and reg is
MsgBox "Is this the correct Employer? " & ActiveCell.Offset(0, 2),
vbYesNo, " Confirm "
Dim Response As Variant
Response = MsgBox(Text, vbYesNo, Titletext)
If Response = vbYes Then
' submit the data to the relevant cells (working)
ActiveCell.Offset(0, 22).Range("A1").Select
ActiveCell.Value = (claimnoint)
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.Value = (daysint)
' clear the cells for next entry
regint.Value = ""
claimnoint.Value = ""
daysint.Value = ""
MsgBox "Submitted", vbOKOnly, " Status "
Cells(1, 1).Select
Exit Sub
ElseIf Response = vbNo Then
Exit Sub
End If

'show message box if match not found
errorhandler:
MsgBox "Reg not found! Please retry", vbOKOnly, "Registration not
found"
regint.Value = ""
regint.SetFocus

End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default msgbox answer

Thank you so much. Works perfectly. I must strive to understand the
properties of dim and why its needed as its something i have never
used!

Thanks again, your help is much appreciated.

Duncan

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
Calculator Answer Doesn't Match Excel Answer GwenH Excel Discussion (Misc queries) 3 October 20th 08 10:17 AM
ABOUT MSGBOX Andy Excel Programming 3 July 25th 05 03:42 AM
i cant get the exact answer e.g answer is 13.49% i got 13.00% zai Excel Discussion (Misc queries) 3 June 9th 05 01:00 PM
Msgbox Wildman Excel Worksheet Functions 1 April 26th 05 04:57 AM
Msgbox help JonoB Excel Programming 2 October 27th 03 03:06 PM


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