Results 1 to 3 of 3

Thread: Where is the problem?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    33

    Where is the problem?

    I am trying to make it so that the text in 4 textboxes are added to the last row of a table, and thought of this:

    VB Code:
    1. Private Sub CommandButton1_Click()
    2. ColumnA = Range("A4:A1000")
    3. For Each c In ColumnA
    4.     If c = "" Then
    5.         c = TextBox1.Text
    6.         Exit For
    7.     End If
    8. Next c
    9. For Each c In Range("B4:B1000")
    10.     If c = "" Then
    11.         c = TextBox2.Text
    12.         Exit For
    13.     End If
    14. Next c
    15. For Each c In Range("C4:C1000")
    16.     If c = "" Then
    17.         c = TextBox3.Text
    18.         Exit For
    19.     End If
    20. Next c
    21. For Each c In Range("A4:A1000")
    22.     If c = "" Then
    23.         c = TextBox4.Text
    24.         Exit For
    25.     End If
    26. Next c
    27. End Sub
    However it does absolutely nothing. Any ideas?

  2. #2
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Where is the problem?

    One thing I noticed is that ColumnA is incorrectly assigned - you need to use "set"

    VB Code:
    1. 'ColumnA = Range("A4:A1000") won't work
    2. Dim ColumnA as Range
    3. Set ColumnA = Range("A4:A1000")

    VBAhack

  3. #3
    Addicted Member
    Join Date
    Jan 2005
    Posts
    138

    Re: Where is the problem?

    You should declare your variables. It would make it easier to analyse.

Posting Permissions

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



Click Here to Expand Forum to Full Width