Multiplying and dividing textboxes

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
22
Hello all,
I was wondering if any one can help with this:

Code:
Private Sub Userform_Activate()
TextBox3.Value = Sheets("Template").Range("AW" & Day(TextBox1.Value) + 7).Value
End Sub


Private Sub CMDADD_Click()
Sheets("Template").Range("AW" & Day(TextBox1.Value) + 7) = TextBox2.Value / (TextBox4.Value * 8.34) + TextBox3.Value
Unload Me
ThisWorkbook.Sheets("MAIN PAGE").Activate
ThisWorkbook.Save
End Sub


Private Sub CMDCLOSE_Click()
Unload Me
End Sub


Private Sub UserForm_Click()
End Sub

Private Sub UserForm_Initialize()
TextBox1.Value = Date
End Sub


Everything works like it should when there is a value on the spreadsheet in "AW" cell, if there is no value in the cell then it wont add the data and goes to debug. If I get rid of + textbox3.value it works but then it wont add the gallons together. Thanks for any help
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How about adding this if block to the activate code?

Code:
Private Sub Userform_Activate()
    TextBox3.Value = Sheets("Template").Range("AW" & Day(TextBox1.Value) + 7).Value
    If TextBox3.Value = "" Then
        TextBox3.Value = "0"
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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