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

macros

ResolvedVersion 2003

Linda has attended:
Excel Advanced course
Excel VBA Intro Intermediate course

Macros

How would I go about recording a macro involving multiple workbooks, can I use recorder?

Recording the opening of a workbook

Hi Linda

The simple answer is YES, you can use the macro recorder to record the code involving multiple workbooks. The example I give below was recorded by me and from an open workbook it opens another workbook, brings some data across and then closes the workbook.

Sub Test

Workbooks.Open Filename:="C:My Documents\Accounts 2007.xls"

Windows("Accounts 2008.xls").Activate
Range("J7").Select
ActiveCell.FormulaR1C1 = "='[Accounts 2007.xls]Sheet1'!R9C4"
Windows("Accounts 2007.xls").Close

End Sub

You can then edit the code for better use; like stopping the screen updating so the user doesn't see the other workbook being accessed.

Hope this helped

Carlos

 

Training courses

Training information:

See also:

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:

Counting Non Number Cells (Text)

If you try to use the COUNT FUNCTION =COUNT(Cell range)with a range of cells with numbers and or containing text fields you wil find that that the text cells will be excluded from the the count. If you want to include them try the the COUNTA FUNCTION =COUNTA(Cell range). This counts both text and number cell values.

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.