View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default VB Form to populate spreadsheet.

Hi Glenn,

Here is the code

Dim cLastRow As Long

cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
If cLastRow = 1 And Cells(cLastRow, "A") = "" Then
Else
cLastRow = cLastRow + 1
End If
With UserForm1
Cells(cLastRow, "A").Value = txtname.Text
Cells(cLastRow + 1, "A").Value = txtpol.Text
Cells(cLastRow + 2, "A").Value = txtaddress.Text
'etc.
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Glenn Robertson" wrote in message
...
Hi,

I am trying to find the best command I can use in visual
basic to do the following.
I have a user form with some textboxes and combo boxes.
txtname, txtpol, txtaddress etc.
I want a macro that when pushed will take this info and
put it into my spreasheet on row 1.
txtname = A1
txtpol = A2 etc.
But if another case is entered i need vb to populate the
next free row rather than insert the info over info
currently there.