Macro Run-time Error 1004 Application Defined or Object Defined Error

A

Anddmx

I have Added 3 Sheets to Excel sheets that I use and disable macr
because it wouldnt work with my new sheet.
The purpose of this excel spreed sheet is to count of page in th
boxes.

I added 3 sheets and tried adding in the new code I am no expert so
am looking for some help with the code that I have added on. When
debug, I get Run-time Error 1004 Application Defined or Object Define
Error and stop here.

Example of where the code stops

continuation:

counter = counter + 2
*Stops* ---> ActiveCell.Offset(1, -counter).Select.Text

While (ActiveCell.Value <> "")

GoTo continuehere


If someone could please guide me in the right direction I would reall
appreciate it.

Thanks

More Code


Sub Record_Page_Count()

Dim Box_number As String
Dim strDocbaseName As String
Dim strUser As String
Dim strPassword As String
Dim strDomain As String
Dim intCount As Integer
Dim pgCounttotal As Integer
Dim pgCount As Integer

'Declare DFC variables
Dim e As IDfException 'Exception object
Dim clientx As IDfClientX 'DFC COM interface object
Dim client As IDfClient 'DFC local client object

Dim loginInfo As IDfLoginInfo

Dim session As IDfSession

Dim q As IDfQuery
Dim col As IDfCollection

Dim strDQL As String

Dim obj As IDfTypedObject

Dim Batch_no As String

Sheets("Boxes").Select
Range("A2").Select
Sheets("ReproMetrics").Select
Rows("3:1000").Select
Selection.ClearContents
Sheets("DailyMetrics").Select
Rows("3:1000").Select
Selection.ClearContents
Sheets("FOMetrics").Select
Rows("3:1000").Select
Selection.ClearContents
Sheets("COMetrics").Select
Rows("3:1000").Select
Selection.ClearContents
Sheets("WCDMetrics").Select
Rows("3:1000").Select
Selection.ClearContents




If (ActiveCell.Value = "REPRO") Then
ActiveCell.Offset(0, 1).Select
Box_number = ActiveCell.Value
Sheets("ReproMetrics").Select
Range("A3").Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select
While (ActiveCell.Value <> "")
counter = counter + 1
Selection.Copy
Sheets("ReproMetrics").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste
Batch_no = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
GoTo Record_Page_Count

Result_RecordsCount:
ActiveCell.Value = intCount
ActiveCell.Offset(0, 1).Select
GoTo PageCount4
Result_PageCount4:
ActiveCell.Value = pgCounttotal
ActiveCell.Offset(1, -3).Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select

Wend



ElseIf (ActiveCell.Value = "DAILY") Then

ActiveCell.Offset(0, 1).Select
Box_number = ActiveCell.Value
Sheets("DailyMetrics").Select
Range("A3").Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select
While (ActiveCell.Value <> "")
counter = counter + 1
Selection.Copy
Sheets("DailyMetrics").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste
Batch_no = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
GoTo Record_Page_Count1

Result_RecordsCount1:
ActiveCell.Value = intCount
ActiveCell.Offset(0, 1).Select
GoTo PageCount5
Result_PageCount5:
ActiveCell.Value = pgCounttotal
ActiveCell.Offset(1, -3).Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select

Wend

ElseIf (ActiveCell.Value = "CO") Then
ActiveCell.Offset(0, 1).Select
Box_number = ActiveCell.Value
Sheets("COMetrics").Select
Range("A3").Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select
While (ActiveCell.Value <> "")
counter = counter + 1
Selection.Copy
Sheets("COMetrics").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste
Batch_no = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
GoTo Record_Page_Count8

Result_RecordsCount8:
ActiveCell.Value = intCount
ActiveCell.Offset(0, 1).Select
GoTo PageCount12
Result_PageCount12:
ActiveCell.Value = pgCounttotal
ActiveCell.Offset(1, -3).Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select

Wend

ElseIf (ActiveCell.Value = "FO") Then
ActiveCell.Offset(0, 1).Select
Box_number = ActiveCell.Value
Sheets("FOMetrics").Select
Range("A3").Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select
While (ActiveCell.Value <> "")
counter = counter + 1
Selection.Copy
Sheets("FOMetrics").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste
Batch_no = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
GoTo Record_Page_Count9

Result_RecordsCount9:
ActiveCell.Value = intCount
ActiveCell.Offset(0, 1).Select
GoTo PageCount13
Result_PageCount13:
ActiveCell.Value = pgCounttotal
ActiveCell.Offset(1, -3).Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select


Wend

ElseIf (ActiveCell.Value = "WCD") Then
ActiveCell.Offset(0, 1).Select
Box_number = ActiveCell.Value
Sheets("WCDMetrics").Select
Range("A3").Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select
While (ActiveCell.Value <> "")
counter = counter + 1
Selection.Copy
Sheets("WCDMetrics").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste
Batch_no = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
GoTo Record_Page_Count16

Result_RecordsCount16:
ActiveCell.Value = intCount
ActiveCell.Offset(0, 1).Select
GoTo PageCount20
Result_PageCount20:
ActiveCell.Value = pgCounttotal
ActiveCell.Offset(1, -3).Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select
Wend

End If


GoTo continuation




continuation:

counter = counter + 2
ActiveCell.Offset(1, -counter).Select.Text

While (ActiveCell.Value <> "")

GoTo continuehere

More code if you need to reply and all post it all
 
B

Bob Phillips

Try it without the Select

--

HTH

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

Anddmx

Just comes up in red.

I dunno what to do, I know it has to do with selection of the size.

'ActiveCell.Offset(1, -counter).select is pass this point and now
have many errors.

Result_PageCount4:
ActiveCell.Value = pgCounttot
*Error* ----> ActiveCell.Offset(1, -3).Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select

Thanks for helping me
 
A

Anddmx

*Just comes up in red.

I dunno what to do, I know it has to do with selection of the size.

'ActiveCell.Offset(1, -counter).select is pass this point and now I
have many errors.

Result_PageCount4:
ActiveCell.Value = pgCounttot
Error* ----> ActiveCell.Offset(1, -3).Select
ActiveCell.Value = Box_number
Sheets("Boxes").Select
ActiveCell.Offset(0, 1).Select

Thanks for helping me.

I still has same error now I replaced ActiveCell.Offset(1, -3).Select
with ActiveCell.Offset(0, 1).Select.
Now I get the same error I post the first time.
I am sure this has to do with the placements in sheets but I am lost on
how to correct this problem.

This is a macro button, do I have to edit anything else on this marco
to make this work?
 
B

Bob Phillips

What is the value of counter when it fails, and the address of activecell?
Is it trying to access off-sheet?

--

HTH

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

Anddmx

When I try to compile the code all it does is stops at the same spot. S
I dunno if that mean there is something else wrong in the upper part o
the code. All I need it to do is to look for Key words on the firs
sheet "boxes" the take the count and put them on to there own sheets
there are 6 sheets and there are COMetrics FOMetrics WCDMetrics.

GoTo continuation



continuation:

counter = counter + 2
Stops----> ActiveCell.Offset(1, -counter).Select

While (ActiveCell.Value <> "")

GoTo continuehere

Wend

GoTo jumpout

Would there be a better way of doing this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top