View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Zone[_3_] Zone[_3_] is offline
external usenet poster
 
Posts: 373
Default Looping thru multiple files to produce a consolidated summary by Code

Celeste, since new codes can appear in the Period tables that are not in the
Code Table, it seems it would be easier to first add new codes and their
descriptions to the Code Table. If the answers to my last 2 questions were
Yes, this should work. I didn't know whether you have a source for the code
descriptions, so I just included an inputbox for them. Paste this code in a
standard module and run it. It if works to add the new codes and their
descriptions, then we'll proceed. James

Sub CreateSummary()
Dim k As Long, Sht As Integer
Dim newDesc As String
'check that codes are in Code Table
Worksheets(1).Activate
For Sht = 2 To 3
With Worksheets(Sht)
For k = 3 To .Cells(3, "a").End(xlDown).Row
If Not FindCode(.Cells(k, "a")) Then
newDesc = InputBox("Enter description " _
& " for Code " & .Cells(k, "a"))
If newDesc = "" Then
Exit Sub
Else
Cells(3, "a").End(xlDown).Offset(1) _
= .Cells(k, "a")
Cells(3, "b").End(xlDown).Offset(1) _
= newDesc
End If
End If
Next k
End With
Next Sht
End Sub

Function FindCode(myCode) As Boolean
Dim c As Range
FindCode = False
Set c = Columns(1).Find(myCode, _
Lookat:=xlWhole, LookIn:=xlValues)
If Not c Is Nothing Then FindCode = True
End Function

"Zone" wrote in message
...
Ok, I'll start diddling with the code to make it work for this. More
questions.
1. You say no more periods will be added, BUT there will be 12. Does
this mean you want to only show the additional periods on the combined
table as they are populated?
2. Do the tables have 2 heading rows, such as
Code Table
Code Descr
in rows 1 and 2, with data beginning in row 3 and
Period1 Data
Code Value Date
in rows 1 and 2, with data beginning in row 3, etc.?
James
"u473" wrote in message
oups.com...
Thank you for your help.
Answers to your questions :
1. Are all the codes and their descriptions listed in the Code Table
on Sheet 1?
That is one of the issues. New codes will pop up in Periods.
I can either be prompted to enter them on the fly on the Code
Table
or populate an Exception worksheet, Both solutions are ok.
2. Do all the tables begin in cell A1, with a heading row in row 1?
Yes
3. Will more periods be added ? ; No How many periods might there
be eventually? : 12