user form problem

J

jimapos

I have a userform in a workbook and i want every time i fill in the form 1.to add a record in sheet1.xls (a1,b1.c1.d1.e1.and so on-in the same workbook) 2.and the same info in another sheet2.xls (b5,c8.d9 and so on ) and then print sheet2.xls
i know its a litlle bi tricky but can anyone help
where can i find some userforms examples in the we
 
B

Bob Phillips

I guess your main problem is adding to the end.

Here is an example adding two textboxes to a sheet

With ActiveWorkbook.Worksheets("Sheet1")
cNextRow = .Cells(Rows.Count,"A").End(xlUp).Row + 1
.Range("A" & cNextRow).Value = Textbox1.Text
.Range("B & cNextRow).Value = Textbox2Text
End With

This code would go in the userform module, triggered by a commandbutton say.




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

jimapos said:
I have a userform in a workbook and i want every time i fill in the form
1.to add a record in sheet1.xls (a1,b1.c1.d1.e1.and so on-in the same
workbook) 2.and the same info in another sheet2.xls (b5,c8.d9 and so on )
and then print sheet2.xls.
 
J

jim apos

Thanks Bob for your help but there was an error on your answer.


With ActiveWorkbook.Worksheets("Sheet1")
cNextRow = .Cells(Rows.Count,"A").End(xlUp).Row + 1
.Range("A" & cNextRow).Value = Textbox1.Text

.Range("B & cNextRow).Value = Textbox2.Text
End With

This code would go in the userform module, triggered by a commandbutton
say.
The last two lines give a red error ...
Please sent me an example.xls with a userform if you can .If you cant
..thanks anyway.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
B

Bob Phillips

Hi Jim,

Corrected the errors, and here it is tied to the commandbutton

Private Sub CommandButton1_Click()
Dim cNextRow As Long
With ActiveWorkbook.Worksheets("Sheet1")
cNextRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
.Range("A" & cNextRow).Value = TextBox1.Text
.Range("B" & cNextRow).Value = TextBox2.Text
End With

End Sub



--

HTH

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