View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
tankerman tankerman is offline
external usenet poster
 
Posts: 60
Default VB button not working

I have a VB in my workbook but I'm having trouble with it (I did not write
this I just made some changes to fit my workbook). I have 26 different sheets
(one for each months individual product movements-we track start and finish
time , one for each months totals, we track the number of times the 30 or so
different products were handled each months (I have a SUMPRODUCT taking care
of this part), plus we have a sheet totalling the years total of all
movements. It took me a month to get all of this setup, what I am trying to
do is have a USERFORM to fill out all of the info of the movements because we
have 15 different people filling out the movement at different times because
we are on a shared drive.

PROBLEM I keep getting a RUN-TIME ERROR '9' when I debug it highlights a
line in me VB, it is the fourth row down. My workbook sheets are like this
JAN 07, JAN TOTALS, FEB 07, FEB TOTALS... plus our total tally sheets.

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

'check for a barge number
If Trim(Me.txtBargeID.Value) = "" Then
Me.txtBargeID.SetFocus
MsgBox "Please enter a barge name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtBargeID.Value
ws.Cells(iRow, 2).Value = Me.txtProd.Value
ws.Cells(iRow, 3).Value = Me.txtStartDate.Value
ws.Cells(iRow, 4).Value = Me.txtFinishDate.Value
ws.Cells(iRow, 9).Value = Me.txtLorP.Value


'clear the data
Me.txtBargeID.Value = ""
Me.txtProd.Value = ""
Me.txtStartDate.Value = ""
Me.txtFinishDate.Value = ""
Me.txtLorP.Value = ""
Me.txtBargeID.SetFocus

End Sub