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:

Leith Ross

Well-known Member
Joined
Mar 17, 2008
Messages
1,872
Office Version
2010, 2007
Platform
Windows
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
 

Forum statistics

Threads
1,082,575
Messages
5,366,405
Members
400,887
Latest member
tporeda

Some videos you may like

This Week's Hot Topics

Top