Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Saving files based on lookup

Hi,

I have many many files which I want to save in different folders. All files
has a number in C1 and based on that number, I need to do a lookup in a
separate file containing the name of the folder. The file has to saved in
the corresponding folder.

Ex:
File A has number 123 in cell C1
Folder-file looks like this:
Number Foldername
123 Folder A
234 Folder B
etc.
In this example, Folder A is the correct folder, and the file needs to be
moved from the current location to the subfolder "Folder A".
Repeat for all files in top-folder.

I guess this is quite simple to program in VBA ..... if you know how.....

Any help would be most appreciated.

Regards,
André

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Saving files based on lookup

Hi Andre,

I found this in the archive. Maybe it will help.

Hi,
I need to save 1 workbook into different folders based on cell.value
The folders are already created in a directory with a customer number
(5
digits).

On the workbook, the customer number is saved in E:1. If more than one
customer, the values are comma separated.

Based on these values, the macro should find the folder for each
customer
and save the file on that folder adding today's date to the sheet
name.
Last, delete the original file (It is saved in a temp folder)

any ideas I will greatly appreciate. Thanks
Gaba


2. Chip Pearson
Newsgroups: microsoft.public.excel.programming
From: Chip Pearson
Date: Wed, 25 Feb 2009 17:10:25 -0600
Local: Wed, Feb 25 2009 4:10 pm
Subject: Save 1 file to different folders based on cell.value

Try code like the following:

Sub AAA()
Dim V As Variant
Dim N As Long
Dim FileName As String
V = Split(Range("E1"), ",")

For N = LBound(V) To UBound(V)
FileName = "C:\" & CStr(V(N)) & "\" & ThisWorkbook.Name
On Error Resume Next
Kill FileName
On Error GoTo 0
ThisWorkbook.SaveCopyAs FileName
Next N
ThisWorkbook.ChangeFileAccess xlReadOnly
Kill ThisWorkbook.FullName
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

3. Gaba
View profile
Thanks Chip for your quick answer. I'm getting an error 400 (?) it is
saving only the first value when I have more than one (comma
separated). If I have only one value, no error, no problem. Any ideas?
Thanks in advance, Gaba -
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Saving files based on lookup

Thank you for your reply

I still need to find the folder name in a seperate list, based on a number
in each file. Any suggestions on how to do this?


André


"DanDungan" skrev i nyhetsmeldingen:
...

Hi Andre,

I found this in the archive. Maybe it will help.

Hi,
I need to save 1 workbook into different folders based on cell.value
The folders are already created in a directory with a customer number
(5
digits).

On the workbook, the customer number is saved in E:1. If more than one
customer, the values are comma separated.

Based on these values, the macro should find the folder for each
customer
and save the file on that folder adding today's date to the sheet
name.
Last, delete the original file (It is saved in a temp folder)

any ideas I will greatly appreciate. Thanks
Gaba


2. Chip Pearson
Newsgroups: microsoft.public.excel.programming
From: Chip Pearson
Date: Wed, 25 Feb 2009 17:10:25 -0600
Local: Wed, Feb 25 2009 4:10 pm
Subject: Save 1 file to different folders based on cell.value

Try code like the following:

Sub AAA()
Dim V As Variant
Dim N As Long
Dim FileName As String
V = Split(Range("E1"), ",")

For N = LBound(V) To UBound(V)
FileName = "C:\" & CStr(V(N)) & "\" & ThisWorkbook.Name
On Error Resume Next
Kill FileName
On Error GoTo 0
ThisWorkbook.SaveCopyAs FileName
Next N
ThisWorkbook.ChangeFileAccess xlReadOnly
Kill ThisWorkbook.FullName
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

3. Gaba
View profile
Thanks Chip for your quick answer. I'm getting an error 400 (?) it is
saving only the first value when I have more than one (comma
separated). If I have only one value, no error, no problem. Any ideas?
Thanks in advance, Gaba -

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
lookup help. lookup result based on data in 2 columns lcc Excel Worksheet Functions 3 April 6th 10 01:20 PM
macro to lookup value and open tab based on lookup value brandyvine Excel Programming 3 December 16th 08 09:57 AM
Closing files and saving files dan Excel Worksheet Functions 0 August 15th 06 04:07 AM
Sumproduct - Condition based on lookup of a Lookup Hari Excel Discussion (Misc queries) 12 May 31st 06 09:28 AM
Saving different files based upon data in particular column DKY[_46_] Excel Programming 14 August 6th 05 04:27 PM


All times are GMT +1. The time now is 02:28 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"