Textbox Only Returns Zeroes

Oprichnick

Board Regular
Joined
May 30, 2013
Messages
69
Hello,
I've been trying to build an userform in which I have several textboxs. In one TextBox I want to insert numbers and letters, in all others I just want numbers. All are returned in a table.

I Thought it would be an easy task.... Though I only get zeroes in the table. I don't understand and tried a lot to understand where is the mistake. But it still doesn't work....

Here is my code:
Code:
Private Sub OkButton_Click()

Dim Btcn As String
Dim PH As Integer
Dim PS As Integer
Dim Cld As Integer
Dim Pdr As Integer
Dim Vrd As Integer
Dim Ptd As Integer
Dim Def As Integer


Dim NextRow1 As Long
Dim NextRow2 As Long
Dim NextRow3 As Long
Dim NextRow4 As Long
Dim NextRow5 As Long
Dim NextRow6 As Long
Dim NextRow7 As Long
Dim NextRow8 As Long


    TextBox1.Value = Btcn
    TextBox2.Value = PH
    TextBox3.Value = PS
    TextBox4.Value = Cld
    TextBox5.Value = Pdr
    TextBox6.Value = Vrd
    TextBox7.Value = Ptd
    TextBox8.Value = Def


    NextRow1 = Application.WorksheetFunction.CountA(Range("A:A")) + 1
    NextRow2 = Application.WorksheetFunction.CountA(Range("B:B")) + 1
    NextRow3 = Application.WorksheetFunction.CountA(Range("C:C")) + 1
    NextRow4 = Application.WorksheetFunction.CountA(Range("D:D")) + 1
    NextRow5 = Application.WorksheetFunction.CountA(Range("E:E")) + 1
    NextRow6 = Application.WorksheetFunction.CountA(Range("F:F")) + 1
    NextRow7 = Application.WorksheetFunction.CountA(Range("G:G")) + 1
    NextRow8 = Application.WorksheetFunction.CountA(Range("H:H")) + 1


    Cells(NextRow1, 1) = Btcn
    Cells(NextRow2, 2) = PH
    Cells(NextRow3, 3) = PS
    Cells(NextRow4, 4) = Cld
    Cells(NextRow5, 5) = Pdr
    Cells(NextRow6, 6) = Vrd
    Cells(NextRow7, 7) = Ptd
    Cells(NextRow8, 8) = Def
    


End Sub

Thanks in advance,
Regards
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hello Oprichnick,

You are assigning the empty values to the TextBoxes. Yo need to reverse them. Try this...
Code:
Private Sub OkButton_Click()

    Dim Btcn As String
    Dim PH As Integer
    Dim PS As Integer
    Dim Cld As Integer
    Dim Pdr As Integer
    Dim Vrd As Integer
    Dim Ptd As Integer
    Dim Def As Integer


    Dim NextRow1 As Long
    Dim NextRow2 As Long
    Dim NextRow3 As Long
    Dim NextRow4 As Long
    Dim NextRow5 As Long
    Dim NextRow6 As Long
    Dim NextRow7 As Long
    Dim NextRow8 As Long


        Btcn = TextBox1.Value
        PH = TextBox2.Value
        PS = TextBox3.Value
        Cld = TextBox4.Value
        Pdr = TextBox5.Value
        Vrd = TextBox6.Value
        Ptd = TextBox7.Value
        Def = TextBox8.Value


        NextRow1 = Application.WorksheetFunction.CountA(Range("A:A")) + 1
        NextRow2 = Application.WorksheetFunction.CountA(Range("B:B")) + 1
        NextRow3 = Application.WorksheetFunction.CountA(Range("C:C")) + 1
        NextRow4 = Application.WorksheetFunction.CountA(Range("D:D")) + 1
        NextRow5 = Application.WorksheetFunction.CountA(Range("E:E")) + 1
        NextRow6 = Application.WorksheetFunction.CountA(Range("F:F")) + 1
        NextRow7 = Application.WorksheetFunction.CountA(Range("G:G")) + 1
        NextRow8 = Application.WorksheetFunction.CountA(Range("H:H")) + 1


        Cells(NextRow1, 1) = Btcn
        Cells(NextRow2, 2) = PH
        Cells(NextRow3, 3) = PS
        Cells(NextRow4, 4) = Cld
        Cells(NextRow5, 5) = Pdr
        Cells(NextRow6, 6) = Vrd
        Cells(NextRow7, 7) = Ptd
        Cells(NextRow8, 8) = Def

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,231
Messages
6,123,754
Members
449,118
Latest member
kingjet

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