Process only filled out textboxes on cmd button click

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,364
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have two question relating to a userform.

First, if the user enters values in textbox1 and textbox2, but does not enter anything in textbox4 how can I prevent the error that bascially says textbox4 is empty. Same thing for textbox1 and/or textbox2 are empty yet textbox4 contains a value.

So in the end both textbox1 and textbox2 need to be filled out before they can process a result in Textbox3.

Also, I thought the [hh]:mm would allow the processing of time over 24 hours like it will in spreadsheet cell, but it doesn't seem to be cooperating.

Code:
Private Sub CommandButton1_Click()
    TextBox3.Value = Format(TextBox1.Value / TextBox2.Value, "0.00")
    TextBox5.Value = Format(TextBox4 / 1440, "[hh]:mm")
End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,215,824
Messages
6,127,092
Members
449,358
Latest member
Snowinx

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