Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

macro copy and paste

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Macro: copy and paste tabs

Macro: copy and paste tabs

ResolvedVersion 2003

Heather has attended:
Excel VBA Intro Intermediate course

Macro: copy and paste tabs

I use a macro created by an ex-colleague which copied and pasted two tabs from a workbook into a new book.

It was done by recording a macro and in the past has copied and pasted both worksheets as values (both have many formulae). However i have made some adjustments to some formulae and now only these paste as "=N/A" when i run the macro. I have stepped through the macro and it is very early on where the "N/A"s appear.

The coding is as follows:

Sheets(Array("INPUT", "JOURNALS")).Select
Sheets("JOURNALS").Activate
Sheets(Array("INPUT", "JOURNALS")).Copy
Sheets(Array("INPUT", "JOURNALS")).Select

Is there any reason an adjusted formula would not copy accross? THe formula is as follows:

=IF(K26<>0,(VLOOKUP(K26,'CALL AC'!Print_Area,2,FALSE))," ")

Thanks,

Heather

RE: Macro: copy and paste tabs

I may have worked this our or at least found a if not the ideal solution. The vlookup was looking up values in a seperate tab. I then copied the table the formula was looking up into the current tab which i was copying and pasting, and it worked without N/As i then extended the macro to delete the table once the tabs had been copied.

Do copied and pasted as new book tabs not lookup in other tabs?

Thanks,

Heather

RE: Macro: copy and paste tabs

Hi Heather

Thanks for getting in touch. I believe the VLOOKUP is generating the #N/A because the FALSE argumented is selected. This means any item not found will be returned #N/A.

It is difficult to see without seeing the source data, but my guess is when the data was pasted the references were not updated, so the formula did not know to look in the other book where the table resides.

I hope this helps, if you have any further questions please let us know.

Kind regards

Gary Fenn
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Fri 23 Nov 2012: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Make macros work in newer versions of Excel

If you have created macros in Excel 97 or 2000 that you want to be able to use in 2002/XP or 2003, you may need to alter the macro security settings in the newer version of Excel you are using.

To do this, go to Tools - Options - Security.

Select Macro Security and change the security setting to Low.

Tick the boxes next to 'Trust Add-ins' and 'Trust Visual Basic' and click OK.

After you have restarted Windows, you should then be able to use your macros created in earlier versions of Excel.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.