Autofilter with offset

camandab

Board Regular
Joined
Feb 10, 2010
Messages
79
Hello, I'm attempting to copy data between workbooks. I'm not sure if this method is the most efficient but the columns in the workbooks are not in the same order so I am copying one at a time.

When I execute this code, it is copying 2 columns at a time instead of 1. I can't figure out why. If I can figure out how/why it is copying 2 columns instead of 1, then I can figure out how to do multiple columns at a time in the future, if needed. Thanks in advance for the help! :)


Code:
With L3sheet
    .AutoFilterMode = False
    With Range("A1", Range("B" & Rows.Count).End(xlUp))
        .AutoFilter 1, "=" & CoCode
        .AutoFilter 2, "=" & Account
        On Error Resume Next
        .Offset(1, 3).SpecialCells(12).Copy Destination:=ws.Cells(lastA, 2).Offset(14, 0)   
        .Offset(1, 2).SpecialCells(12).Copy Destination:=ws.Cells(lastA, 3).Offset(14, 0)   
        On Error GoTo 0
        End With
        End With
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Because the range you have offset from is a 2 column range

With Range("A1", Range("B" & Rows.Count).End(xlUp)) 'This is 2 columns A:B
.Offset(1, 3).SpecialCells(12).Copy


Offset just moves over the specified rows and columns, does not alter the size/shape of the originally referenced range...

Try

.Offset(1, 3).Resize(, 1).SpecialCells(12).Copy
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,443
Members
452,915
Latest member
hannnahheileen

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