Multiplying and dividing textboxes

kevinc1973

New Member
Joined
Jun 20, 2019
Messages
15
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
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

shknbk2

Board Regular
Joined
Mar 5, 2016
Messages
238
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
 

Watch MrExcel Video

Forum statistics

Threads
1,095,747
Messages
5,446,255
Members
405,392
Latest member
Steveoaktree1977

This Week's Hot Topics

Top