Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Pulling files in using Macros

Hello

I am trying to write a macro that prompts the user to choose 2 files to
open. The problem is that the files have the same name, but they are located
under two different folders. (The folders are different years, the files are
of the same type with different data.) I really don't want to go back and
change all the names of the files. Is there a way to search within different
folders?

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Pulling files in using Macros

If the situation is that it is always this year and last year as an example,
have the user choose the file name, then open that filename from each
folder.

nm = InputBox("Enter filename")
sStr1 = "C:\2006\" & nm
sStr2 = "C:\2005\" & nm

Note that you can't have two files open with the same name, so you would
have to work with them sequentially.

--
Regards,
Tom Ogilvy



"MSHO" wrote in message
...
Hello

I am trying to write a macro that prompts the user to choose 2 files to
open. The problem is that the files have the same name, but they are

located
under two different folders. (The folders are different years, the files

are
of the same type with different data.) I really don't want to go back and
change all the names of the files. Is there a way to search within

different
folders?

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pulling files in using Macros


There are a whole bundle of different ways to do what you want so it is
really down to what you want to achieve. If you can clarify that then
we can help a bit further

Meanwhile; I presume that what you are trying to do is to ask which
year to open and then open just that file.

If the folders are arranged in a tidy form eg ...\2005\wkb.xls and
....\2006\wkb.xls then what I would do is not to search for the file but
to ask for the year. Then you can form the folder name using the reply
and open the wkb as normal.

If you really need a selection list then I suggest using a form with a
listbox populated with file and folder names (use the filesystem object
to compile the list) Then using a selection on the form open the file or
files as appropriate.

A


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=500135

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Pulling files in using Macros

If I want to prompt for the year too, can i do that with an input box and put
it into the "C:\...."?

Thanks so much!

"Tom Ogilvy" wrote:

If the situation is that it is always this year and last year as an example,
have the user choose the file name, then open that filename from each
folder.

nm = InputBox("Enter filename")
sStr1 = "C:\2006\" & nm
sStr2 = "C:\2005\" & nm

Note that you can't have two files open with the same name, so you would
have to work with them sequentially.

--
Regards,
Tom Ogilvy



"MSHO" wrote in message
...
Hello

I am trying to write a macro that prompts the user to choose 2 files to
open. The problem is that the files have the same name, but they are

located
under two different folders. (The folders are different years, the files

are
of the same type with different data.) I really don't want to go back and
change all the names of the files. Is there a way to search within

different
folders?

Thanks





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Pulling files in using Macros

This is what I have so far... and it's not working... any clue?

Sub Macro2()

Dim filetypenm
filetypenm = InputBox("Enter File Name you would like to compare")

Dim nm
nm = InputBox("Enter Year you would like to compare")
Dim sStr1
sStr1 = "C:\Desktop\Coop Students\Small Package Rates\UPS Rates\" & nm \ " &
filetypenm"

Dim nm1
nm1 = InputBox("Enter Year you would like to compare it to")
Dim sStr2
sStr2 = "C:\Desktop\Coop Students\Small Package Rates\UPS Rates\" & nm1 \ "
& filetypenm"


End Sub

"tony h" wrote:


There are a whole bundle of different ways to do what you want so it is
really down to what you want to achieve. If you can clarify that then
we can help a bit further

Meanwhile; I presume that what you are trying to do is to ask which
year to open and then open just that file.

If the folders are arranged in a tidy form eg ...\2005\wkb.xls and
...\2006\wkb.xls then what I would do is not to search for the file but
to ask for the year. Then you can form the folder name using the reply
and open the wkb as normal.

If you really need a selection list then I suggest using a form with a
listbox populated with file and folder names (use the filesystem object
to compile the list) Then using a selection on the form open the file or
files as appropriate.

A


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=500135




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Pulling files in using Macros

I added application.getopenfilename("C:\Desktop\Coop Students\Small Package
Rates\UPS Rates\" & nm \ " & filetypenm") instead of sStr1 but it still
doesnt work

I think it's my code. Any corrections would be appreciated

"MSHO" wrote:

This is what I have so far... and it's not working... any clue?

Sub Macro2()

Dim filetypenm
filetypenm = InputBox("Enter File Name you would like to compare")

Dim nm
nm = InputBox("Enter Year you would like to compare")
Dim sStr1
sStr1 = "C:\Desktop\Coop Students\Small Package Rates\UPS Rates\" & nm \ " &
filetypenm"

Dim nm1
nm1 = InputBox("Enter Year you would like to compare it to")
Dim sStr2
sStr2 = "C:\Desktop\Coop Students\Small Package Rates\UPS Rates\" & nm1 \ "
& filetypenm"


End Sub

"tony h" wrote:


There are a whole bundle of different ways to do what you want so it is
really down to what you want to achieve. If you can clarify that then
we can help a bit further

Meanwhile; I presume that what you are trying to do is to ask which
year to open and then open just that file.

If the folders are arranged in a tidy form eg ...\2005\wkb.xls and
...\2006\wkb.xls then what I would do is not to search for the file but
to ask for the year. Then you can form the folder name using the reply
and open the wkb as normal.

If you really need a selection list then I suggest using a form with a
listbox populated with file and folder names (use the filesystem object
to compile the list) Then using a selection on the form open the file or
files as appropriate.

A


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=500135


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
Pulling Data, References and Flat Files GF08 Excel Discussion (Misc queries) 1 November 19th 09 10:19 PM
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
Automatically Pulling Cells from Different Tabs and Files bscuga Excel Discussion (Misc queries) 1 April 8th 09 02:28 PM
Pulling data from multiple files Whois Clinton Excel Discussion (Misc queries) 5 June 9th 08 02:46 PM
Macros pulling info from other worksheets [email protected] Excel Worksheet Functions 3 December 7th 07 10:01 AM


All times are GMT +1. The time now is 08:56 PM.

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"