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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Range Object Failed

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
I have a block of code that I have used in many other places that works just fine. However in one spot it keeps failing. When I click on the Help button the microsoft Help just comes up blank. It wont tell me anything. Can anyone spot the problem?

Excel 2003
Run-time error '1004':
Method 'Range' of object '_Worksheet' failed


Code:
Dim wkSht as Excel.Worksheet, xlRng as Excel.Range, ActionList as ActionItemList, wkSource as Excel.Worksheet
Dim strTitle as String
Const shtAILManage as string = "AIL Manager"

    Set wkSource = Worksheets(strTitle)
    Set ActionList = New ActionItemList
    Set wkSht = Worksheets(shtAILManager)
    'Clear Previous Contents
        If wkSht Is Nothing Then
            Err.Raise 91 'Object not set
        End If
        [highlight]wkSht.Range(Rows(5), Rows(500)).Hidden = False[/highlight]
        With wkSht
            Set xlRng = .Range(Rows(5), Rows(500))
            xlRng.Delete
            Set xlRng = Nothing
        End With

-JTBorton
Another Day, Another Disaster
 
What about this ?
Code:
    'Clear Previous Contents
        If wkSht Is Nothing Then
            Err.Raise 91 'Object not set
        End If
        With wkSht
            .Range(.Rows(5), .Rows(500)).Hidden = False
            .Range(.Rows(5), .Rows(500)).Delete
        End With
Notice the dots ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top