LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Data Update Loops between Folders

This is a simple case of data save from Current to Previous before
updating with New import data.
I made progress in VBA but I still fumble with Syntax & Loops between
Folders, Workbooks and Worksheets.
I need one more push for 2008. Happy New Year to All.
..
Step 1 : Before importing the new CurrentCostToDate from the Cost
History Folder / Latest Month Data,
I have to save the CurrentCostToDate Field values into the
PreviousCostToDate field Values
of the Active WorkSheet.

Structure of folder to be updated
All Workbooks have this name format : #####-g#

Folder TIC711
Workbook 51693-g0
Worksheet 51693
Workbook 51693-g1
Worksheet 51693
Workbook 61101-g0
Worksheet 61101
Workbook 61101-g2
Worksheet 61101
Workbook 61151-g0
Worksheet 61151
Etc...

Logic : Path : C:\Reports
Input Prompt for Folder name ' TIC711
Loop thru all workbooks in this Folder
if righ(Workbook.name,1)="0" 'Like 61101-g0
Sheets(1).activate 'Only
the first Sheet is to be updated
Retrieve Lastrow
CopyRange H10: H & LastRow 'CurrentCostToDate
Range to be copied
Copy CopyRange.values to P10 'Copy to
PreviousCostToDate Field
End If
Next workbook
..
Separate macro, though I could later combine this second update macro
with the fist one.
Step 2 : Update the CurrentCostToDate values (Range H10:H160),
in the same selected workbooks above,
from Source CostHistory Folder, Latest Month Workbook
thru a Vlookup of CostCode Range

Structure of Source folder VlookedUp to update the current looped
worksheet

Folder CostHistory
Workbook Dec07
Worksheet 51693
Worksheet 61101
Worksheet 61151
Worksheet 61191
........................
Workbook Nov07
Worksheet 51693
Etc...
..
Logic: Source Path : C:\CostHistory
Destin. Path : C:\Reports
Input Prompt for Source workbook name ' Dec07
Input Prompt for Destin. Folder name ' TIC711
Loop thru all workbooks in Destination Folder
if righ(Workbook.name,1)="0" 'Like 61101-g0
Sheets(1).activate ' Only the first Sheet
is to be updated
Retrieve Lastrow in Column A in ActiveSheet
DestinRange : H10: H & LastRow 'Range to be
updated
Find ActiveSheet.Name in Source Workbook worksheets
names
Retrieve SourceLastrow in Column A in found Source
workSheet
SourceRange : H2: H & SourceLastRow
For Each Cell in DestinRange
CostCode in Destination Sheet used in Vlookup
is in Column A
sCostCode in Source sheet used in Vlookup is
in Column A
Current Cell.value =
Vlookup(CostCode,sCostCode,SourceRange).value
Next Cell
End If
Next workbook
 
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
How can I update 2 or 3 duplicate workbooks in separate folders? LindaK Excel Discussion (Misc queries) 1 July 14th 09 04:02 AM
Get data from Outlook Public Folders in Excel Wim VR[_2_] Excel Programming 0 August 17th 07 03:06 PM
Using Do Loops to copy data Mahnian Excel Programming 6 April 27th 07 11:52 PM
Vlookup macro that returns data from worksheet, then Loops xlsxlsxls[_3_] Excel Programming 4 October 23rd 04 05:48 PM
Vlookup macro that returns data from worksheet, then Loops xlsxlsxls[_4_] Excel Programming 0 October 23rd 04 05:43 PM


All times are GMT +1. The time now is 08:40 AM.

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

About Us

"It's about Microsoft Excel"