dwarek

Board Regular
Joined
Jul 15, 2016
Messages
79
Hello i want to display a pop up message when a particular textbox is empty in the userform before i click on the command button...is there any kind of vba code for that???
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Something like this:
Code:
Private Sub CommandButton1_Click()
    If Len(textBox1.Text) = 0 Then
        MsgBox "The text box is empty", vbCritical
        Exit Sub
    End If
End Sub
 
Upvote 0
this works fine after clicking the command button but the problem is remaining textboxes where i have entered the value for example the value i enter in textbox 2 and textbo3 are getting entered into the worksheet but yes i have a pop up message also, so i need solution like before clicking the command button a pop up message should appear if that particular textbox is empty or if that particular textbox is empty the remaing values which i enter in other textbox should not get enter into the worksheet......is there any kind of solution?????
 
Upvote 0
Go there - don't know where, take that - don't know what.
Could you give example workbook and detailed algorithm because Vanga is on vacation?
 
Last edited:
Upvote 0
So this is my program when i have empty space in textbox 4,5 and 6 i should get a pop message that i have not entered value in these field before clicking on the command button or else if i have empty space in these textboxes a pop menu should appear after clicking the command button but the values which i enter in the remaining field should not get entered into the worksheet,because if it happens i need cancel the userform then delete the entry which is made and again from the beginning i need to enter the data which is time consuming process

Private Sub CommandButton1_Click()
Dim lrow As Long
Dim x As Long
Dim y As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet1")


lrow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lrow, 2).Value = TextBox1.Value
.Cells(lrow, 3).Value = TextBox2.Value
.Cells(lrow, 5).Value = TextBox3.Value
.Cells(lrow, 8).Value = TextBox4.Value
.Cells(lrow, 9).Value = TextBox5.Value
.Cells(lrow, 10).Value = TextBox6.Value
.Cells(lrow, 14).Value = TextBox7.Value
.Cells(lrow, 11).Value = TextBox8.Value




If OptionButton1 = True Then
.Cells(lrow, 4).Value = "NEW"
ElseIf OptionButton2 = True Then
.Cells(lrow, 4).Value = "MODIFY"
ElseIf OptionButton3 = True Then
.Cells(lrow, 4).Value = "NAR"
ElseIf OptionButton4 = True Then
.Cells(lrow, 4).Value = "REX"
End If


If OptionButton5 = True Then
.Cells(lrow, 6).Value = "YES"
ElseIf OptionButton6 = True Then
.Cells(lrow, 6).Value = "NO"
End If


If OptionButton7 = True Then
.Cells(lrow, 11).Value = "EQ/EQTY/ALL"
ElseIf OptionButton8 = True Then
.Cells(lrow, 11).Value = "FI/ALL/ALL"
ElseIf OptionButton9 = True Then
.Cells(lrow, 11).Value = "FI/CORP/ALL"
ElseIf OptionButton10 = True Then
.Cells(lrow, 11).Value = "FI/GOVT/ALL"
End If


If OptionButton11 = True Then
.Cells(lrow, 7).Value = "3 TO 10"
ElseIf OptionButton12 = True Then
.Cells(lrow, 7).Value = "LESS THAN 10"
ElseIf OptionButton13 = True Then
.Cells(lrow, 7).Value = "MORE THAN 10"
End If


If OptionButton14 = True Then
.Cells(lrow, 12).Value = "ADDING NEW SSI"
ElseIf OptionButton15 = True Then
.Cells(lrow, 12).Value = "DELETED SSI"
ElseIf OptionButton16 = True Then
.Cells(lrow, 12).Value = "SSI ALREADY PRESENT WITH CORRECT DATA AND FORMAT"
ElseIf OptionButton17 = True Then
.Cells(lrow, 12).Value = "UPDATE TO EXISTING SSI"
ElseIf OptionButton18 = True Then
.Cells(lrow, 12).Value = "UPDATETO FORMAT OF EXISTING SSI"
End If




End With


Static rngUR As Range: Set rngUR = ActiveWorkbook.ActiveSheet.UsedRange
Dim rngBlank As Range: Set rngBlank = rngUR.Find("")

While Not rngBlank Is Nothing
rngBlank.Value = rngBlank.Offset(-1, 0).Value
Set rngBlank = rngUR.Find("", rngBlank)
Wend


Dim ctrl
For Each ctrl In Me.Controls
If TypeOf ctrl Is msforms.TextBox Then
ctrl.Text = ""
End If
If TypeOf ctrl Is msforms.OptionButton Then
ctrl.Value = False
End If
Next ctrl



End Sub


Private Sub CommandButton2_Click()


Unload Newalert


End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top