Copy and paste not the same size

Tucker92

Board Regular
Joined
Jun 7, 2018
Messages
53
I have been trying to copy and paste selected filtered columns from one work book to another but i keep getting the same error about them not being the same size. I can copy and paste them manually but it wont let me do it through my vba code.

Can anyone please take a look and let me know if it is possible and what i have done wrong

Thank you

Here is my code

Code:
 Sub Copy_12Met_WTL()

Dim ws As Worksheet
Dim Vac As Worksheet
    Set Vac = Application.Workbooks("Vac AC").Sheets("12 Metal")
    Set ws = Application.ActiveSheet


Dim str As String
    str = "12""MET"
          
        
   ws.Range("WTL").AutoFilter field:=3, Criteria1:="=*" & str & "*", VisibleDropDown:=True
If ws.ListObjects("WTL").Range.Columns(1).SpecialCells(xlCellTypeVisible).Count > 1 Then
            
    Dim data_end_row_number As Long
    Dim nxt As Long
     data_end_row_number = ws.Range("A3").End(xlDown).Row
     nxt = Vac.Range("A2").End(xlDown).Row + 1
     
            ws.Range("D" & data_end_row_number).SpecialCells(xlCellTypeVisible).copy Destination:=Workbooks("Vac AC").Sheets("12 Metal").Range("B" & nxt)
            ws.Range("A" & data_end_row_number).SpecialCells(xlCellTypeVisible).copy Destination:=Workbooks("Vac AC").Sheets("12 Metal").Range("A" & nxt)
            ws.Range("E" & data_end_row_number).SpecialCells(xlCellTypeVisible).copy Destination:=Workbooks("Vac AC").Sheets("12 Metal").Range("F" & nxt)
    
    Else
    MsgBox "No Carry Over For 12 Metal Line"
            End If
    End Sub
 
Thank you yea that does it works perfectly. would you be able to explain why it didn't work before but now does and what was causing the issue please.

not long been learning vba and curious.

Thank you
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Code:
[COLOR=#333333]Range("A" & data_end_row_number)[/COLOR]
is one cell. This is exactly the same than
Code:
cells([COLOR=#333333]data_end_row_number,"A")[/COLOR]
or
Code:
cells([COLOR=#333333]data_end_row_number,1)[/COLOR]

If you want a range of multiple cells, you can for example use someting like
Code:
Range("A3:A"&[COLOR=#333333]data_end_row_number)[/COLOR]
or
Code:
Range(cells(3,"A"),cells([COLOR=#333333]data_end_row_number,1))[/COLOR]
or even
Code:
Range(Range("A3"),cells([COLOR=#333333]data_end_row_number,"A"))[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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