PDA

Click to See Complete Forum and Search --> : Where is the problem?


Jonno12345
Apr 28th, 2005, 12:41 PM
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:

Private Sub CommandButton1_Click()
ColumnA = Range("A4:A1000")
For Each c In ColumnA
If c = "" Then
c = TextBox1.Text
Exit For
End If
Next c
For Each c In Range("B4:B1000")
If c = "" Then
c = TextBox2.Text
Exit For
End If
Next c
For Each c In Range("C4:C1000")
If c = "" Then
c = TextBox3.Text
Exit For
End If
Next c
For Each c In Range("A4:A1000")
If c = "" Then
c = TextBox4.Text
Exit For
End If
Next c
End Sub
However it does absolutely nothing. Any ideas?

VBAhack
Apr 28th, 2005, 02:09 PM
One thing I noticed is that ColumnA is incorrectly assigned - you need to use "set"

'ColumnA = Range("A4:A1000") won't work
Dim ColumnA as Range
Set ColumnA = Range("A4:A1000")

VBAhack

D-niss
Apr 29th, 2005, 12:11 AM
You should declare your variables. It would make it easier to analyse.