简体   繁体   中英

VBA How to copy range data without headers

I have a problem because I have code that copies entire columns, but I would like to change this code to copy only the values under the headers because in the second file I have pivot tables set. copy vintage file but would like to start with A2: C2

wbMe.Sheets("input_4").Range("A:D").ClearContents
wb.Sheets("vintage_agr").Columns("A:C").Copy
wbMe.Sheets("input_4").Range("A1").PasteSpecial Paste:=xlPasteValues

wb.Sheets("vintage_agr").Columns("H").Copy
wbMe.Sheets("input_4").Range("D1").PasteSpecial Paste:=xlPasteValues

在此处输入图像描述

This Should work..

wbMe.Sheets("input_4").Range("A:D").ClearContents
wb.Sheets("vintage_agr").Range("A2:C" & rows.count-1).Copy
wbMe.Sheets("input_4").Range("A1").PasteSpecial Paste:=xlPasteValues

wb.Sheets("vintage_agr").Range("H2:H" & rows.count-1).Copy
wbMe.Sheets("input_4").Range("D1").PasteSpecial Paste:=xlPasteValues

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM