Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I update 2 or 3 duplicate workbooks in separate folders? | Excel Discussion (Misc queries) | |||
Get data from Outlook Public Folders in Excel | Excel Programming | |||
Using Do Loops to copy data | Excel Programming | |||
Vlookup macro that returns data from worksheet, then Loops | Excel Programming | |||
Vlookup macro that returns data from worksheet, then Loops | Excel Programming |