Results 1 to 4 of 4

buggy macro 'intersect' of object of object'_global failed" when deleting rows

Threaded View

  1. #1
    Registered User
    Join Date
    09-19-2011
    Location
    Birmingham
    MS-Off Ver
    Excel 2003 - 07
    Posts
    69

    buggy macro 'intersect' of object of object'_global failed" when deleting rows

    hey all sorry to keep bothering you all have used my limited knolage to try and de bug this but no avail.
    it says "method 'intersect' of object of object'_global failed"
    Public Sub CommandButton1_Click()
    Dim wbRead As Workbook
    
    
    Set wbRead = Workbooks.Open("C:\Users\u524717\Desktop\" & Sheets(1).Range("A1").Value)
    With wbRead.Sheets(1)
            ThisWorkbook.Sheets(2).Range("a:ah").Value = .Range("A:ah").Value
    End With
    wbRead.Close True
       Sheets("Sheet1").Range("B:D").ClearContents
        Sheets("Sheet2").Range("A:D,F:L,N:R,T:AG").Delete Shift:=xlToLeft
        Sheets("Sheet2").Range("1:8,10:11").Delete Shift:=xlUp
        ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.clear
        ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Add Key:=Range("D1"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("Sheet2").Sort
            .SetRange Range("A2:D1217")
            .Header = xlNo
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        Sheets("sheet2").Activate
            With Intersect(ActiveSheet.UsedRange, Columns("d"))    <------ points to here
            .AutoFilter 1, ">20"
            .Offset(1).EntireRow.Delete
            .AutoFilter
        End With
        With Intersect(ActiveSheet.UsedRange, Columns("C"))
            .AutoFilter 1, "=0"
            .Offset(1).EntireRow.Delete
            .AutoFilter
        End With
        ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
            "Sheet2!R1C1:R65536C4", Version:=xlPivotTableVersion10).CreatePivotTable _
            TableDestination:="Sheet1!R2C2", TableName:="PivotTable1", DefaultVersion _
            :=xlPivotTableVersion10
        Sheets("Sheet1").Select
        Cells(2, 2).Select
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("Material")
            .Orientation = xlRowField
            .Position = 1
        End With
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("Gate")
            .Orientation = xlRowField
            .Position = 2
        End With
        ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
            "PivotTable1").PivotFields("Total WIP"), "Count of Total WIP", xlCount
        With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of Total WIP")
            .Caption = "Sum of Total WIP"
            .Function = xlSum
        End With
       
    
    End Sub
    many thanks for this you are all gods!!!!
    Last edited by Kezwick; 10-18-2011 at 07:32 AM. Reason: solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1