First thought is that you spelled something wrong and that either the sheet Problem3 does not exist or the named range PaymentAmount does not exist on the sheet Problem3. Double check for leading and trailing spaces as they matter.
Edit:
Here, run this code as a separate subroutine. It should tell you if what I think is correct.
Sub Test_for_Range()
Dim SheetName As String, NamedRange As String
''''''''''''''''''''''''''''''''''''''''''''''''
'
' Enter the sheet name and named range you want
' to test for:
SheetName = "Problem3"
NamedRange = "PaymentAmount"
'
''''''''''''''''''''''''''''''''''''''''''''''''
Dim ws As Worksheet: Set ws = Nothing
Dim rng As Range: Set rng = Nothing
Dim str As String
On Error Resume Next
Set ws = Sheets(SheetName)
Set rng = Sheets(SheetName).Range(NamedRange)
If Not ws Is Nothing And Not rng Is Nothing Then
str = "The worksheet: " & SheetName & " exists." & vbCr _
& "The named range: " & NamedRange & " exists."
ElseIf Not ws Is Nothing And rng Is Nothing Then
str = "The worksheet: " & SheetName & " exists." & vbCr _
& "The named range: " & NamedRange & " does not exist."
Else
str = "The worksheet " & SheetName & " does not exist. Correct it and rerun code to verify the named range."
End If
On Error GoTo 0
MsgBox str
End Sub
Bookmarks