Home > Enterprise >  VBA How to copy range data without headers
VBA How to copy range data without headers

Time:10-05

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

enter image description here

CodePudding user response:

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
  • Related