Consulting

Results 1 to 10 of 10

Thread: CODE CANT BE WORK

  1. #1
    VBAX Contributor
    Joined
    Jun 2008
    Posts
    169
    Location

    CODE CANT BE WORK

    Dear Experts

    This is my 1st time to learn aboutb the USERFORM AND HAVE CREAT ONE BUT HAVE NOT WORK !! CODE AS BELOW,

    KINDLY PLEASE HELP TO SEE AND LEARN ME ABOUT WHAT'S WAS I MADE A WRONG ,,,THXX

    WHAT'S THE USERFORM TO DO;

    TEXTBOX 1 = WS SHEET1 COL: A COUNT THE BLANK ROWS.
    TEXTBOX 2 = WS SHEET1 COL: B COUNT THE BLANK ROWS.
    TEXTBOX 3 = WS SHEET1 COL: C COUNT THE BLANK ROWS.
    TEXTBOX 4 = WS SHEET1 COL: D COUNT THE BLANK ROWS.

    CODE:

    [VBA]
    Private Sub CommandButton1_Click()
    Unload UserForm3
    End Sub
    Private Sub OKButton1_Click()
    With Sheets("Sheet1")
    Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1
    Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1
    Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1
    Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1
    TextBox1 = Range("A" & r).Value = Value
    TextBox2 = Range("B" & r).Value = Value
    TextBox3 = Range("C" & r).Value = Value
    TextBox4 = Range("D" & r).Value = Value

    End Sub

    Private Sub TextBox1_Change()
    Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1
    Range("A" & r).Value = Value
    End Sub

    Private Sub TextBox2_Change()
    Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1
    Range("B" & r).Value = Value
    End Sub

    Private Sub TextBox3_Change()
    Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1
    Range("C" & r).Value = Value
    End Sub

    Private Sub TextBox4_Change()
    Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1
    Range("D" & r).Value = Value
    End Sub
    Private Sub UserForm_Click()
    End Sub
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    So it doesn't work. In what way? What does it do it shouldn't, or doesn't do that it should.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Jun 2008
    Posts
    169
    Location
    Dear XLD

    Thanks your help & replying
    When I put the values in the four TextBox, then OK, but the object WS has not showing the value I think the code has marking wrong and hope here someone help too,

    I wan t to the userform to do is when I put a value in the textbox that?s should paste in object WS counts col A and rows blank to pasts.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Surely; all you need is

    [vba]

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub


    Private Sub OKButton1_Click()
    Dim r As Long

    With Sheets("Sheet1")
    .Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox1.Text
    .Range("B" & .Range("B" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox2.Text
    .Range("C" & .Range("C" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox3.Text
    .Range("D" & .Range("d" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox4.Text
    End With
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor
    Joined
    Jun 2008
    Posts
    169
    Location
    Thanks the help,
    I still testing it what I is previously marking wrong before,
    Although changed your code that?s the text can?t fall in to object WS?

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You will have to explain better and more comprehensively. Either I don't know what you are trying to do, or I don't understand what is wrong, or both.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Contributor
    Joined
    Jun 2008
    Posts
    169
    Location
    Dear XLD

    Thanks your help

    I trying to describe what?s I want to do,

    TextBox value = aim to Worksheet sheet1 form col A to down, count blank cells that?s faill in what was I type in the userform textbox,

    Your code seem before work base the criteria, but I don?t know the background which is duplicated or wrong as I still in testing
    Posted as here?s

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub
    Private Sub OKButton1_Click()
    Dim r As Long

    With Sheets("TEL_LIST")
    .Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox1.Text
    .Range("B" & .Range("B" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox2.Text
    .Range("C" & .Range("C" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox3.Text
    .Range("D" & .Range("d" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox4.Text
    End With
    End Sub

    Private Sub TextBox1_Afterupdate()
    Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1

    Range("A" & r).Value = Value
    End Sub

    Private Sub TextBox2_Afterupdate()
    Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1

    Range("B" & r).Value = Value
    End Sub

    Private Sub TextBox3_afterupdate()
    Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1

    Range("C" & r).Value = Value
    End Sub

    Private Sub TextBox4_afterupdate()
    Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1

    Range("D" & r).Value = Value
    End Sub

    Private Sub UserForm_Click()

    End Sub

  8. #8
    VBAX Contributor
    Joined
    Jun 2008
    Posts
    169
    Location
    Dear XLD

    Thanks your help

    I trying to describe what?s I want to do,

    TextBox value = aim to Worksheet sheet1 form col A to down, count blank cells that?s faill in what was I type in the userform textbox,

    Your code seem before work base the criteria, but I don?t know the background which is duplicated or wrong as I still in testing
    Posted as here?s

    Private Sub CommandButton1_Click()
    Unload Me
    End Sub
    Private Sub OKButton1_Click()
    Dim r As Long

    With Sheets("TEL_LIST")
    .Range("A" & .Range("A" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox1.Text
    .Range("B" & .Range("B" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox2.Text
    .Range("C" & .Range("C" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox3.Text
    .Range("D" & .Range("d" & .Rows.Count).End(xlUp).Row + 1).Value = TextBox4.Text
    End With
    End Sub

    Private Sub TextBox1_Afterupdate()
    Dim r As Long: r = Range("A" & Rows.Count).End(xlUp).Row + 1

    Range("A" & r).Value = Value
    End Sub

    Private Sub TextBox2_Afterupdate()
    Dim r As Long: r = Range("B" & Rows.Count).End(xlUp).Row + 1

    Range("B" & r).Value = Value
    End Sub

    Private Sub TextBox3_afterupdate()
    Dim r As Long: r = Range("C" & Rows.Count).End(xlUp).Row + 1

    Range("C" & r).Value = Value
    End Sub

    Private Sub TextBox4_afterupdate()
    Dim r As Long: r = Range("d" & Rows.Count).End(xlUp).Row + 1

    Range("D" & r).Value = Value
    End Sub

    Private Sub UserForm_Click()

    End Sub

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sorry mate, I can't help, I just don't understand.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    VBAX Contributor
    Joined
    Jun 2008
    Posts
    169
    Location
    That's it ...but anyway ,thanks too much

Posting Permissions

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