Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default If then MsgBox

On Userform1, I have TextBox1. I am trying to acheive the following... If
when the user clicks CommandButton1 and Textbox1 equals "" or "Enter Stat
Name here", then I would like a message box to popup telling the user
"INVALID DATA". If when the user clicks CommandButton1 and Textbox1 does
not equal "" or "Enter Stat Name here", then I would like the code to
continue to the next part of the code which would be the message box saying
"Are you sure?" Right now I am getting errors in the first messagebox.

Below is what I have so far?

Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or "Enter Stat Name here" Then
MsgBox("Invalid Data", vbOKOnly) = vbOKOnly
Else
End If
If MsgBox("Are you sure?", vbYesNo) = vbNo Then
Exit Sub
End If
End Sub

Thanx
Todd Huttenstine


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default If then MsgBox

One way:

Private Sub CommandButton1_Click()
With TextBox1
If .Value = "" Or .Value = "Enter Stat Name here"
MsgBox("Invalid Data", vbOKOnly)
Exit Sub
End If
End With
If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub
'vbYes, so do something...
End Sub



In article ,
"Todd Huttenstine" wrote:

On Userform1, I have TextBox1. I am trying to acheive the following... If
when the user clicks CommandButton1 and Textbox1 equals "" or "Enter Stat
Name here", then I would like a message box to popup telling the user
"INVALID DATA". If when the user clicks CommandButton1 and Textbox1 does
not equal "" or "Enter Stat Name here", then I would like the code to
continue to the next part of the code which would be the message box saying
"Are you sure?" Right now I am getting errors in the first messagebox.

Below is what I have so far?

Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or "Enter Stat Name here" Then
MsgBox("Invalid Data", vbOKOnly) = vbOKOnly
Else
End If
If MsgBox("Are you sure?", vbYesNo) = vbNo Then
Exit Sub
End If
End Sub

Thanx
Todd Huttenstine


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default If then MsgBox

Thanx, that worked.

Todd


"J.E. McGimpsey" wrote in message
...
One way:

Private Sub CommandButton1_Click()
With TextBox1
If .Value = "" Or .Value = "Enter Stat Name here"
MsgBox("Invalid Data", vbOKOnly)
Exit Sub
End If
End With
If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub
'vbYes, so do something...
End Sub



In article ,
"Todd Huttenstine" wrote:

On Userform1, I have TextBox1. I am trying to acheive the following...

If
when the user clicks CommandButton1 and Textbox1 equals "" or "Enter

Stat
Name here", then I would like a message box to popup telling the user
"INVALID DATA". If when the user clicks CommandButton1 and Textbox1

does
not equal "" or "Enter Stat Name here", then I would like the code to
continue to the next part of the code which would be the message box

saying
"Are you sure?" Right now I am getting errors in the first messagebox.

Below is what I have so far?

Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or "Enter Stat Name here" Then
MsgBox("Invalid Data", vbOKOnly) = vbOKOnly
Else
End If
If MsgBox("Are you sure?", vbYesNo) = vbNo Then
Exit Sub
End If
End Sub

Thanx
Todd Huttenstine




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
msgbox peyman Excel Discussion (Misc queries) 2 September 29th 07 08:21 PM
MsgBox CC Excel Discussion (Misc queries) 4 May 5th 06 05:45 PM
MsgBox redmad Excel Programming 1 August 1st 03 12:18 AM
MsgBox Dave Peterson[_3_] Excel Programming 0 July 23rd 03 02:11 AM
MsgBox Phil Perry Excel Programming 1 July 9th 03 07:38 PM


All times are GMT +1. The time now is 11:14 AM.

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

About Us

"It's about Microsoft Excel"