Macro to Import Data Excel to Excel [Closed]

- - Latest reply: venkat1926
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
- Aug 25, 2011 at 06:19 AM
Hello,

Let me preface with the fact that I am using Excel 2003, pretty fluent with Excel in general, but new to the macros and visual basic - although I'm learning as fast as I can. I have muddled my way through a great deal of code so far, but am hung up on the following:

I'm trying to create a macro that will import a dynamic data range from one Workbook to another workbook. Once Workbook I, whose filename will vary, is open, I need to import data from Workbook 2, whose filename and location will vary.

The range of data to be imported from Workbook 2 is dynamic. By that I mean, it will always have the same # of columns (A:S) and start at row 10 (yes row 10, not 1 or 2), the last row # will vary.

I've tried recording a macro opening Workbook 1, then opening Workbook 2, then copying and pasting the data from Workbook 2 to Worbook 1, but the filenames, locations and data range are static, and I can't figure out how to make them dynamic.

When I tried recording a macro using Import External Data I figure out how to work around the fact that the data starts on row 10, not 1.

Thank you, in advance, for any assistance you can provide.



See more 

1 reply

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
784
0
Thank you
I shall give you a clue

suppose you open book1 and later book2
then if you go windows(menu) you see book2 will be seen in the first and book1 is in second.

you goto book1 and in immediate window type
windows(1).activate
you get book2 opens whatever be the name of the workbook.

so instead of workbooks use windows. try some experiments as you are familiar with excel.