Im getting an Application defined or Object defined Error on a macro

Phantasm

Board Regular
Joined
Nov 2, 2007
Messages
58
I have no idea why I am getting an error on this. It was working fine earlier. The error happens on the line that is bold.

Rich (BB code):
Sub SHIPJOB(control As IRibbonControl)

With Sheets("JOBS IN PROCESS NEW")

If .AutoFilterMode Then .AutoFilterMode = False

.Range("A1:O1").AutoFilter 15, "x"

.AutoFilter.Range.Offset(1).Copy Sheets("SHIPPED ORDERS").Range("A" & Rows.Count).End(xlUp).Offset(1)

.AutoFilter.Range.Offset(1).EntireRow.Delete

.AutoFilterMode = False

If Not Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter Then

Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter

End If

ActiveWorkbook.Sheets(3).Activate

Rows("2:150").RowHeight = 16.5

End With

End Sub
 
Last edited by a moderator:
Still getting an error, but now its "Object variable or With block variable not set" on the bold line of code

Sub SHIPJOB(control As IRibbonControl)
With Sheets("JOBS IN PROCESS NEW")
If .AutoFilterMode Then .AutoFilterMode = False
.Range("A:O").AutoFilter 15, "x"
.AutoFilter.Range.Offset(1).Resize(.AutoFilter.Range.Rows.Count - 1).Copy Sheets("SHIPPED ORDERS").Range("A" & Rows.Count).End(xlUp).Offset(1)
.AutoFilter.Range.Offset(1).Resize(.AutoFilter.Range.Rows.Count - 1).EntireRow.Delete
.AutoFilterMode = False
If Not Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter Then
Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter
End If
ActiveWorkbook.Sheets(3).Activate
Rows("2:150").RowHeight = 16.5
End With
End Sub
 
Last edited:
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
As I explained earlier in the thread your range is too large to offset. So resize BEFORE the offset

amend that line to this
Code:
.AutoFilter.Range.[COLOR=#ff0000]Resize(.AutoFilter.Range.Rows.Count - 1)[/COLOR].[COLOR=#006400]Offset(1)[/COLOR].Copy Sheets("SHIPPED ORDERS").Range("A" & Rows.Count).End(xlUp).Offset(1)
 
Upvote 0
In post #9 I put a small correction:


Change "A:O" by "A1:O1"

Code:
Sub SHIPJOB(control As IRibbonControl)
    With Sheets("JOBS IN PROCESS NEW")
        If .AutoFilterMode Then .AutoFilterMode = False
        .Range("[COLOR=#ff0000]A1:O1[/COLOR]").AutoFilter 15, "x"
        .AutoFilter.Range.Offset(1).Resize(.AutoFilter.Range.Rows.Count - 1).Copy Sheets("SHIPPED ORDERS").Range("A" & Rows.Count).End(xlUp).Offset(1)
        .AutoFilter.Range.Offset(1).Resize(.AutoFilter.Range.Rows.Count - 1).EntireRow.Delete
        .AutoFilterMode = False
        If Not Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter Then
            Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter
        End If
        ActiveWorkbook.Sheets(3).Activate
        Rows("2:150").RowHeight = 16.5
    End With
End Sub
 
Upvote 0
As I explained earlier in the thread your range is too large to offset. So resize BEFORE the offset

amend that line to this
Code:
.AutoFilter.Range.[COLOR=#ff0000]Resize(.AutoFilter.Range.Rows.Count - 1)[/COLOR].[COLOR=#006400]Offset(1)[/COLOR].Copy Sheets("SHIPPED ORDERS").Range("A" & Rows.Count).End(xlUp).Offset(1)

Same error with this:


Sub SHIPJOB(control As IRibbonControl)
With Sheets("JOBS IN PROCESS NEW")
If .AutoFilterMode Then .AutoFilterMode = False
.Range("A1:O1").AutoFilter 15, "x"
.AutoFilter.Range.Resize(.AutoFilter.Range.Rows.Count - 1).Offset(1).Copy Sheets("SHIPPED ORDERS").Range("A" & Rows.Count).End(xlUp).Offset(1)
.AutoFilter.Range.Offset(1).Resize(.AutoFilter.Range.Rows.Count - 1).EntireRow.Delete
.AutoFilterMode = False
If Not Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter Then
Worksheets("JOBS IN PROCESS NEW").Range("A1:O1").AutoFilter
End If
ActiveWorkbook.Sheets(3).Activate
Rows("2:150").RowHeight = 16.5
End With
End Sub
 
Upvote 0
You could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,002
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top