Copying table range to another sheet Vba

afc171

Board Regular
Joined
Jan 14, 2017
Messages
145
Office Version
  1. 2013
Platform
  1. Windows
Hello guys,

I am trying to copy a table which pulls in data so can vary in number of rows. I keep getting a memory error when copying to another sheet..

2Despatch Consumables V1.xlsm
BCDEFGH
1Despatch Consumables
2productlong_descriptionlot_numberbin_numberquantityinspection_dateexpiry_date
3GEN0023Azowipes15278LC14COSH820/Jun/202231/May/2024
4GEN0023Azowipes15852LC14COSH1929/Jul/202230/Jun/2024
5GEN0023Azowipes15959LC14COSH2026/Aug/202230/Jun/2024
6PKG0001BUF BOX 120 X 79 X 60MM300421LC/P829830/Apr/2021
7PKG0001BUF BOX 120 X 79 X 60MM260422LC/P8182126/Apr/2022
8PKG0003BUF BOX SLEEVES LIT.BUF170566KSCLC/P835627/May/2021
9PKG0004BOVINE KIT SLEEVE LIT.KIT BOV090719LC/P86709/Jul/2019
10PKG0004BOVINE KIT SLEEVE LIT.KIT BOV031019LC/P815403/Oct/2019
11PKG0005ICT KIT SLEEVE LIT.KIT PACK031019LC/P836603/Oct/2019
12PKG0006MMT/RMT KIT SLEEVE LIT.MMT169162LCLC/P894930/Sep/2020
13PKG0008SINGLE WALL BROWN BOX 305X228X130MM L25170367KSCLC/P81522/Apr/2021
14PKG0008SINGLE WALL BROWN BOX 305X228X130MM L25211021LC/P810021/Oct/2021
15PKG0009DOUBLE WALL BROWN BOX 305X305X305MM L49167212KSCLC/P85601/Oct/2019
16PKG0010A4 PLAIN DOC ENCLOSED WALLETS 1000/BOX150720LC/P8300015/Jul/2020
17PKG0011A7 PLAIN DOC ENCLOSED WALLETS 1000/BOX091019LC/P8509/Oct/2019
18PKG0013BROWN TAPE LOW NOISE 48MMX66M 36/BOX161121LC/P818016/Nov/2021
19PKG0014BUBBLE BAG 130MMX185MM 500/BOX081221LC/P856008/Dec/2021
20PKG0015SMALL BUBBLE WRAP - 3X500MMX200M210422LC/P8221/Apr/2022
21PKG0016CLEAR TAPE LOW NOISE 48MMX66M 36/BOX031019LC/P810203/Oct/2019
22PKG0017WHITE M/LITE ENV MLPF/3 220X330MM 50/BOX170274KSCLC/P880026/Mar/2021
Despatch-LC-Stock
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B3:I67Expression=ROW(B3)=HighlightStocktextNO


Pasting into Sheet1 gives 1004 runtime memory error..

2Despatch Consumables V1.xlsm
ABCDEFGHI
1Despatch Consumables - Static Stock
2productlong_descriptionlot_numberbin_numberquantityinspection_dateexpiry_dateIDCheck?
Sheet1


VBA Code:
Sub CopyToStatic()

    Range("B3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("A3").Select
    ActiveSheet.Paste
    Range("A1:H1").Select
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try something like this:
Modify sheet names and Table name.
Assuming you are actually talking about a Excel Table
VBA Code:
Sub Copy_Table()
'Modified 10/3/2022  6:04:00 PM  EDT
Sheets("Alpha").ListObjects("One").DataBodyRange.Copy Sheets("Bravo").Range("G3")
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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