Process only filled out textboxes on cmd button click

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,282
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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

FryGirl

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

Forum statistics

Threads
1,175,985
Messages
5,900,735
Members
434,848
Latest member
kubersood321

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