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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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