View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mark kubicki mark kubicki is offline
external usenet poster
 
Posts: 32
Default trouble adding a name...

When I open a workbook, I have code to check all of the worksheets to see if
they have already been "formatted", if not I run code to do so... (new
worksheets are added to the workbook by an external program, and need to be
reformatted into a legible worksheet)
A range name is added to each worksheet to flag it as having been
reformatted (ReformattingComplete = True...) The new sheets do not have the
name; it is added by code (which is where i might be having my problem....

On a new sheet, with no range named (ReformattingComplete) it gets stuck in
an endless loop at the error handler...

any suggestions would be much appreciated,
mark


Private Sub Workbook_Open()
For Each Sheet In Worksheets
If Sheet.Name < "QuickBooks Export Tips" _
And Sheet.Name < "Billing Rates" _
And Sheet.Name < "Project Upset" Then
Worksheets(Sheet.Name).Activate
ReformatWorksheet 'call subroutine to verify formatting
status
End If
Next Sheet
End Sub

------------------------------------------------
Sub ReformatWorksheet()
On Error GoTo errNoNameFound ' new sheets will not have a named range
"ReformatingCompleted"
If ActiveWorkbook.ActiveSheet.Names("ReformatingCompl eted").Value =
"=TRUE" Then
Exit Sub
End If
FormatandAddFormulas 'subrouting to reformat sheet is called
....
errNoNameFound: ' Error-handling routine
ActiveWorkbook.ActiveSheet.Names.Add Name:="ReformatingCompleted",
RefersToR1C1:=False 'add named reange and assign false value