Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default VB button not working

I forgot to mention that I can get the VB to work on my test sheet which has
only 2 sheets but not in my complete work book.

"tankerman" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default VB button not working

Not sure of the problem
I think its becaue the Form subroutine is private. You can try to remove
private and see what happens

Normally the form will get data and the manipulation of the data will take
placve in the main code.

"tankerman" wrote:

I forgot to mention that I can get the VB to work on my test sheet which has
only 2 sheets but not in my complete work book.

"tankerman" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VB button not working

The subscript out of range error (9) means that there is no worksheet in that
workbook that has the name you're using.

So either you don't have a "Mar 07" worksheet--or you're in the wrong workbook.

Maybe...

Set ws = Worksheets("MAR 07")
should be
Set ws = thisworkbook.Worksheets("MAR 07")

Or it could be a simple spelling error (extra spaces in that name???).

tankerman wrote:

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


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default VB button not working


I had the sheet name in caps when I changed the name case it works fine

Thanks everyone for the help.
"Dave Peterson" wrote:

The subscript out of range error (9) means that there is no worksheet in that
workbook that has the name you're using.

So either you don't have a "Mar 07" worksheet--or you're in the wrong workbook.

Maybe...

Set ws = Worksheets("MAR 07")
should be
Set ws = thisworkbook.Worksheets("MAR 07")

Or it could be a simple spelling error (extra spaces in that name???).

tankerman wrote:

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


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VB button not working

The case of the name (Mar 07 or MAR 07 or MaR 07 or...) wouldn't matter. But
when you changed the case, you fixed the other (unknown) problem.

tankerman wrote:

I had the sheet name in caps when I changed the name case it works fine

Thanks everyone for the help.
"Dave Peterson" wrote:

The subscript out of range error (9) means that there is no worksheet in that
workbook that has the name you're using.

So either you don't have a "Mar 07" worksheet--or you're in the wrong workbook.

Maybe...

Set ws = Worksheets("MAR 07")
should be
Set ws = thisworkbook.Worksheets("MAR 07")

Or it could be a simple spelling error (extra spaces in that name???).

tankerman wrote:

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


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default VB button not working


Thanks everyone for the help
"Dave Peterson" wrote:

The case of the name (Mar 07 or MAR 07 or MaR 07 or...) wouldn't matter. But
when you changed the case, you fixed the other (unknown) problem.

tankerman wrote:

I had the sheet name in caps when I changed the name case it works fine

Thanks everyone for the help.
"Dave Peterson" wrote:

The subscript out of range error (9) means that there is no worksheet in that
workbook that has the name you're using.

So either you don't have a "Mar 07" worksheet--or you're in the wrong workbook.

Maybe...

Set ws = Worksheets("MAR 07")
should be
Set ws = thisworkbook.Worksheets("MAR 07")

Or it could be a simple spelling error (extra spaces in that name???).

tankerman wrote:

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

--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
double-click mouse button not working squeezerfan Excel Discussion (Misc queries) 0 November 6th 06 09:28 PM
tab button not working in excel Traci Excel Discussion (Misc queries) 1 November 30th 05 09:38 PM
Tab button not working properly Mike J Setting up and Configuration of Excel 3 June 4th 05 12:14 AM
command button isn't working Nydia New Users to Excel 1 April 29th 05 10:31 PM
Mouse right button not working Jerry S Excel Worksheet Functions 3 April 4th 05 01:35 AM


All times are GMT +1. The time now is 12:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"