View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Create List from Multiple Worksheets

Create a new worksheet that is named summary and use the code below. Column
c on the summary sheet should be formated as text, otherwise, leading zeroes
will be truncated.

Sub zip_code()
Dim Cell_Data As String

zipcode_count = 0
For Each MyWorksheet In Workbooks(ThisWorkbook.Name).Worksheets
If StrComp("Summary", MyWorksheet.Name) < 0 Then
RowCount = 1

Do While StrComp(MyWorksheet.Range("C1"). _
Offset(rowOffset:=RowCount - 1, columnOffset:=0), "End") < 0

Cell_Data =
MyWorksheet.Range("C1").Offset(rowOffset:=RowCount - 1, columnOffset:=0).Value
If Len(Cell_Data) = 5 Then

Found_Char = False

For char_count = 1 To 5
character = Mid(Cell_Data, char_count, 1)
If (character < "0") And (character "9") Then
Found_Char = True
Exit For
End If
Next char_count

If Found_Char = False Then

Worksheets("Summary").Range("C1").Offset(rowOffset :=zipcode_count, _
columnOffset:=0) = Cell_Data
zipcode_count = zipcode_count + 1

End If

End If

RowCount = RowCount + 1


Loop
End If
Next MyWorksheet

End Sub


"David" wrote:

I need to create a list of all zip codes on one worksheet that are contained
on 150 individual worksheets. Each worksheet has zip codes and some text in
column C. I want to create a worksheet at the end of the workbook and run a
macro that will list all the zip codes contained on the 150 worksheets in one
row so I can compare all the zip codes to a master list in another worksheet.
The macro needs to start with sheet 1, look at all the values in Column C,
add the ones that have 5 digit zip codes, and ignore blanks and text, and go
through all worksheets until the last sheet which will contain the list.
Can I get some help?