Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Hnadling when Range not found 1

Status
Not open for further replies.

MacroAlan

Programmer
Dec 4, 2006
134
US
Our supplier sends a zillion spreadsheets with price quotes. Supposedly their system generates these and uses Named Ranges to place the data in the correct place.

I wrote a macro on our end that reads the named ranges and puts everything into a master.

After spinning through the first 50, I found a sheet that was totally missing the Named area I needed to pick up. Is there some syntax that would check for an error?

Code:
 Range("PROPOSAL_SUBTOTAL_MW_HW").Copy       'Point of failure
                WriteBk.Activate
                Cells(W, ContrCols.ppdHWlist).Select
                ActiveSheet.Paste
                    WB.Activate
I tried using On Error Goto something but it just gives me a 1004 Range not found error. If I could just rap the error I could flag the cell as bad for someone to check.


Alan
[smurf]
 
hi,

Use this function IsName as in the test example...
Code:
Sub test()
    MsgBox IsName("PROPOSAL_SUBTOTAL_MW_HW")
End Sub


Function IsName(sName As String) As Boolean
    Dim nm As Name, bFound As Boolean
    
    For Each nm In ActiveWorkbook.Names
        With nm
            If .Name = sName Then
                IsName = True
                Exit For
            End If
        End With
    Next
    
    For Each nm In ActiveSheet.Names
        With nm
            If .Name = sName Then
                IsName = True
                Exit For
            End If
        End With
    Next
End Function


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top