Copying cells to another worksheet

D

Derrick Salmon

Thought this would be simple - its not been today.

I have a workbook with several worksheets and need VBA code to copy the
contents of worksheet "A" to worksheet "B". Both worksheets "A" and
"B" exist before the macros are executed.

Every attempt today has left worksheet B unchanged (essentially empty
except for 4 initial header rows which existed before the attempt at
copying) or has created, then opened another workBook and copied the
contents to worksheet "B" in the new workbook.

Suggestions ?

cheers


Derrick
 
G

Guest

Derrick,
Sorry but please ignore my earlier reply as it will not work in all cases.
So you are better off using the following:

Worksheets("A").Range(Worksheets("A").Range("A1"),Worksheets("A").Cells.SpecialCells(xlCellTypeLastCell)).Copy Worksheets("B").Range("A1")

Note that there is a space character only after Copy and the entire command
should be in one line.(Unless you use the line continuation character.)

Alok
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top