Results 1 to 4 of 4

Thread: Multiplying and dividing textboxes

  1. #1
    New Member
    Join Date
    Jun 2019
    Location
    Syracuse NY
    Posts
    11
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Multiplying and dividing textboxes

    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

  2. #2
    Board Regular
    Join Date
    Mar 2016
    Posts
    221
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Multiplying and dividing textboxes

    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

  3. #3
    New Member
    Join Date
    Jun 2019
    Location
    Syracuse NY
    Posts
    11
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Multiplying and dividing textboxes

    shknbk2,
    Thanks for the code it worked great.
    Thanks Kevin

  4. #4
    Board Regular
    Join Date
    Mar 2016
    Posts
    221
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Multiplying and dividing textboxes

    You're welcome.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •