PDA

View Full Version : Saving data from several objects to 1 cell



bopo
05-21-2007, 05:19 PM
Hi

Well I have some coding which adds data to a sheet and starts a new line, the coding grabs data from textboxes within UserForm, and pastes them into specific columns which is great.

However two of the imports are not working, I think this is due to mutiple text boxes and define, rather than one source. Anyway if anyone thinks something looks wrong, feel free to post.

'########CODES1######
iLastRow = .Cells(.Rows.Count, "E").End(xlUp).Row + 1
.Range("E" & iLastRow).Value = (InvoiceForm.txtcode1.Text) & _
" " & (InvoiceForm.txtcode2.Text) & " " & (InvoiceForm.txtcode5.Text) & _
" " & (InvoiceForm.txtcode6.Text) & ""
'########CODES2######
iLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row + 1
.Range("F" & iLastRow).Value = InvoiceForm.txt1.Text & _
" " & (InvoiceForm.txt2.Text) & " " & (InvoiceForm.txtcode7.Text) & _
" " & (InvoiceForm.txtcode8.Text) & ""

Edit: line breaks addes so code doesn't run off the screen

geekgirlau
05-21-2007, 05:36 PM
When you say it's not working, what do you mean? Have you tested each value individually to see which one is creating the problem?

lucas
05-21-2007, 05:56 PM
I did two of the textboxes in one of your examples.....should help...let us know.
Dim iLastRow As Long
Dim ActSh As Worksheet
Set ActSh = Sheets("Sheet1")
iLastRow = ActSh.Cells(Rows.Count, "E").End(xlUp).Row + 1
Range("E" & iLastRow).Value = (Me.txtcode1.Text) & " " & (Me.txtcode2.Text)