Joel, Your code worked great last month , This month I get an "error 1
TypeMismatch" when I try to run my macro. here is my code the erro
occurs at "If InStr(UCase(.Range("b" & RowCount)), "Total") > 0 Then"
'*********NOTE ADD "TOTAL" TO COLUMN "A" BEFORE EXPANDING AND RUNNIN
THIS MACRO**********************
'ADDITIONAL NOTES CECK COLUMN FOR CONTRACTOR AND COUNT , ELIMINAT
ILLEGAL CHARACTERS IN CONTRACTOR NAMES BEFORE RUNNING
'change directory
Folder = "h:\Contractor Expired\Contractor Expired Apr2010\"
'Folder = "\\dpd-sharepoint\electrical\Contractor Expire
Spreadsheets\April2010"
'assume there is a header row which gets copied to each new sheet
Set Sourcesht = ThisWorkbook.Sheets("Expired")
With Sourcesht
LastRow = .Range("h" & Rows.Count).End(xlUp).Row
'ignore the Grand Total line if one exists
If InStr(UCase(.Range("h" & LastRow)), "GRAND") > 0 Then
LastRow = LastRow - 1
End If
Application.ScreenUpdating = False
StartRow = 2
RowCount = StartRow
For RowCount = StartRow To LastRow
' Application.IsError (CellValue)
If InStr(UCase(.Range("b" & RowCount)), "Total") > 0 Then
client = .Range("H" & StartRow)
'create new workbook
Set newbook = Workbooks.Add(template:=xlWBATWorksheet)
Set newsht = newbook.Sheets(1)
'change sheet name to clients name
newsht.Name = client
'copy header row
.Rows(1).Copy Destination:=newsht.Rows(1)
'copy data
.Rows(StartRow & ":" & RowCount).Copy _
Destination:=newsht.Rows(2)
StartRow = RowCount + 1
'newbook.Active
newbook.SaveAs Filename:=Folder & client
FormatContractorList 'macro that hides some columns in new WB
newbook.Close savechanges:=True
End If
Next RowCount
End With
End Sub
Thank You again for your help
Duane
The code below I didn't test but is very similar to the older macro
You should be able to get it working like the last macro