Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Importing from another file of unknown name

Hi,

I'm not a VB expert by any means (I can follow what code is doing, but
wouldn't really know how to write it) so I'd appreciate someone being able to
solve the following for me:

I have a set of spreadsheets with sequential names, Date 1 Log.xls, Date 2
Log.xls, Date 3 Log.xls etc. Each of these have multiple pages in them, all
with the same names, Page 1, Page 2, Page 3 etc.

I have a separate spreadsheet into which I want to copy data from a specific
page in each sequential spreadsheet. This will always be from the same page
name, ie. Date 1 Log.xls Page 1, Date 2 Log.xls Page 1, Date 3 Log.xls Page 1.

This will be done one Log at a time and the data can overwrite previous
imports (I will be doing other stuff with each set of imported data in
between imports).

What I envisage happening is a user will input the specific Log name, they
will click a button and a macro will import the source page from the correct
Log to the target location. They will then do the maniplation of data that I
need, and then repeat the import with the next Log and manipulate that data
set etc..

Importing data from a known Log name is easy enough, but I will not actually
know the name of the file to be used as the variable is a date stamp in the
Log name.

Can anyone provide a piece of code that will read the value of a specific
cell that contains the name of the source Log (provided by the user - this is
simply a text entry), opens it and copies the source page to the target page?

TIA

Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Importing from another file of unknown name

Sub getdata()

SheetName = ActiveSheet.Name
BookName = Range("A1")

Workbooks.Open Filename:=BookName
ActiveWorkbook.Sheets(SheetName).Cells.Copy _
Destination:=ThisWorkbook.Sheets(SheetName).Cells

End Sub


"Risky Dave" wrote:

Hi,

I'm not a VB expert by any means (I can follow what code is doing, but
wouldn't really know how to write it) so I'd appreciate someone being able to
solve the following for me:

I have a set of spreadsheets with sequential names, Date 1 Log.xls, Date 2
Log.xls, Date 3 Log.xls etc. Each of these have multiple pages in them, all
with the same names, Page 1, Page 2, Page 3 etc.

I have a separate spreadsheet into which I want to copy data from a specific
page in each sequential spreadsheet. This will always be from the same page
name, ie. Date 1 Log.xls Page 1, Date 2 Log.xls Page 1, Date 3 Log.xls Page 1.

This will be done one Log at a time and the data can overwrite previous
imports (I will be doing other stuff with each set of imported data in
between imports).

What I envisage happening is a user will input the specific Log name, they
will click a button and a macro will import the source page from the correct
Log to the target location. They will then do the maniplation of data that I
need, and then repeat the import with the next Log and manipulate that data
set etc..

Importing data from a known Log name is easy enough, but I will not actually
know the name of the file to be used as the variable is a date stamp in the
Log name.

Can anyone provide a piece of code that will read the value of a specific
cell that contains the name of the source Log (provided by the user - this is
simply a text entry), opens it and copies the source page to the target page?

TIA

Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Importing from another file of unknown name

Thanks

"Joel" wrote:

Sub getdata()

SheetName = ActiveSheet.Name
BookName = Range("A1")

Workbooks.Open Filename:=BookName
ActiveWorkbook.Sheets(SheetName).Cells.Copy _
Destination:=ThisWorkbook.Sheets(SheetName).Cells

End Sub


"Risky Dave" wrote:

Hi,

I'm not a VB expert by any means (I can follow what code is doing, but
wouldn't really know how to write it) so I'd appreciate someone being able to
solve the following for me:

I have a set of spreadsheets with sequential names, Date 1 Log.xls, Date 2
Log.xls, Date 3 Log.xls etc. Each of these have multiple pages in them, all
with the same names, Page 1, Page 2, Page 3 etc.

I have a separate spreadsheet into which I want to copy data from a specific
page in each sequential spreadsheet. This will always be from the same page
name, ie. Date 1 Log.xls Page 1, Date 2 Log.xls Page 1, Date 3 Log.xls Page 1.

This will be done one Log at a time and the data can overwrite previous
imports (I will be doing other stuff with each set of imported data in
between imports).

What I envisage happening is a user will input the specific Log name, they
will click a button and a macro will import the source page from the correct
Log to the target location. They will then do the maniplation of data that I
need, and then repeat the import with the next Log and manipulate that data
set etc..

Importing data from a known Log name is easy enough, but I will not actually
know the name of the file to be used as the variable is a date stamp in the
Log name.

Can anyone provide a piece of code that will read the value of a specific
cell that contains the name of the source Log (provided by the user - this is
simply a text entry), opens it and copies the source page to the target page?

TIA

Dave

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a file - Application unknown Snirp Excel Programming 1 April 6th 07 01:02 PM
Refer to Unknown File Name Lynn Excel Programming 1 June 22nd 06 12:38 AM
Open unknown file name Jan Excel Programming 4 March 9th 06 02:51 AM
Paste sheet to new file with unknown file name - VBA [email protected] Excel Programming 2 October 5th 05 05:41 PM
How to Activate unknown file name Ashley[_3_] Excel Programming 1 June 4th 04 06:41 PM


All times are GMT +1. The time now is 03:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"