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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,217,763
Messages
6,138,459
Members
450,140
Latest member
myexcel202424

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