Process only filled out textboxes on cmd button click

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,252
Office Version
  1. 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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,252
Office Version
  1. 2016
Platform
  1. Windows
Any thoughts or suggestions?
 

Forum statistics

Threads
1,141,728
Messages
5,708,134
Members
421,548
Latest member
douae

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
Top