View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Copying info from one workbook to another

You just select the elements that you want to include in the Pivot Table,
right. Are you talking about importing multiple .xls files? If so,m try
this macro:
Sub Import()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Dim x As Long
Dim FilesToOpen

FilesToOpen = Application.GetOpenFilename _
(FileFilter:="Text Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Excel Files to Open")

Set Wb1 = ActiveWorkbook
For x = LBound(FilesToOpen) To UBound(FilesToOpen)
Set Wb2 = Workbooks.Open(Filename:=FilesToOpen(x))

Wb2.Worksheets.Copy _
After:=Wb1.Sheets(Wb1.Sheets.Count)

Wb2.Close False
Next x

End Sub

Again, import the data, build a summary sheet with all the data, and then
use this summary sheet as the basis for your Pivot Table. I do this all the
time; works fine for me...

Regards,
Ryan---

--
RyGuy


"Slow Thinker" wrote:

Thanks Ryan, the page is loaded with info I know I will be able to use but I
still don't see how to get the macro to grab the names of the two open
workbooks to I can work with them.

Barb

"ryguy7272" wrote:

This should give you what you want, and a whole lot more too:
http://www.rondebruin.nl/tips.htm

See the section titled 'Copy/Paste/Merge examples'


Regards,
Ryan---

--
RyGuy


"Slow Thinker" wrote:

I have to copy info from one workbook to another when the workbook layouts
will remain the same but the workbook names will change from session to
session. How do I indentify the open workbooks in my Macro?

Example "Book1" has a column for last name and age. I want to copy the
contents of the last name column and the value of the age column to two
different columns in another book I have opened up. I just can't seem to get
the syntax right. Any help would be greatly appreciated.

Thank you!