PDA

View Full Version : Copy Columns in Selected Sheets to a New Table with the data



christian.as
08-26-2018, 03:00 PM
Hi,

I am looking for a macro that can copy columns in selected sheets:

Copy Columns (A, B, D) in selected Sheets in the workbook and create a new sheet with the data.

The Data should be pasted from Column A and to the right.
For each new sheet copied there should be inserted an empty column.

Thank you in advance for the help

werafa
08-27-2018, 02:32 PM
Hi Christian,

I don't have the code for this to hand, but these pointers should give you the words to look up.

1: create a new worksheet. do this by setting a worksheet object. I believe the code is:

dim newSheet as worksheet
set newSheet = thisworkbook.worksheets.add

now you can call this sheet at any time by "newworksheet.range("A1")" etc.

2: copy and paste columns

you can use copy/paste in vba (there is lots on this in this forum and elsewhere on google)
you can also use the macro recorder to record a copy/paste event to get some workable code - all you would then need to do is manage the ranges you copy and paste to and from.

hope this gives you a start