![]() |
|
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2003
Location: Orlando
Posts: 47
|
I am working with many workbooks trying to merge certian data from each into a master book. The tabs and such are named the same ex. book 701 has sheet 701 and will copy data to masterbook on sheet 701. Therefore I was trying to use a varaiable to do all this. But it is not working, it will not go from sheet to sheet in my masterbook, but paste all on same tab. Below is a bit of the code I am using.
For ProgramLoop = 702 To 703 mySiteNumb = ProgramLoop mySitedoc = ProgramLoop & ".doc" myFilename = "c:\capfiles\" & ProgramLoop & ".doc" Workbooks.OpenText Filename:=myFilename, startrow:=4 ', DataType:=xlDelimited, Space:=True Windows(mySitedoc).Activate Sheets(mySiteNumb).Select Columns("A:D").Select Selection.Copy Windows("South_new_template.xls").Activate <---- master workbook Sheets(mySiteNumb).Select Columns("I:I").Select ActiveSheet.Paste .... More code to filter sort and delete etc..... |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Dec 2002
Posts: 1,199
|
Are you referencing a word document? What's up with the .doc? Or rather... What's up Doc
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Portland, OR
Posts: 380
|
mySiteNumb is an integer so when you try to access your sheet with sheets(mySiteNumb) it is treating it as an index value. Try sheets(ltrim(str(mySiteNumb))).select
-Mike |
|
|
|
|
|
#4 |
|
New Member
Join Date: Apr 2003
Location: Orlando
Posts: 47
|
as for the .doc I am having excel open text file delimited by space. So 702.doc is opened in excel. I will try your example now also ..thanks.
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2003
Location: Orlando
Posts: 47
|
worked great thanks for the help.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|