View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
buckchow[_2_] buckchow[_2_] is offline
external usenet poster
 
Posts: 1
Default Populating worksheet from userform combobox


Listed below is the code I'm having a problem with:


Private Sub UserForm_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
txtBatch1.SetFocus
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.txtBatch1.Value) = "" Then
Me.txtBatch1.SetFocus
MsgBox "Please enter a batch number"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtBatch1.Value
ws.Cells(iRow, 2).Value = Me.txtDate1.Value
ws.Cells(iRow, 3).Value = Me.txtCust1.Value
ws.Cells(iRow, 4).Value = Me.txtBoard1.Value
ws.Cells(iRow, 5).Value = Me.txtSerial1.Value
ws.Cells(iRow, 6).Value = Me.txtQty1.Value
ws.Cells(iRow, 18).Value = Me.txtStatus1.Value
ws.Cells(iRow, 17).Value = Me.txtNotes.Value

'clear the data
Me.txtBatch1.Value = ""
Me.txtDate1.Value = ""
Me.txtCust1.Value = ""
Me.txtBoard1.Value = ""
Me.txtSerial1.Value = ""
Me.txtQty1.Value = ""
Me.txtStatus1.Value = ""
Me.txtNotes.Value = ""
Me.txtBatch1.SetFocus

End Su

--
buckcho
-----------------------------------------------------------------------
buckchow's Profile: http://www.officehelp.in/member.php?userid=597
View this thread: http://www.officehelp.in/showthread.php?t=131886

Posted from - http://www.officehelp.i