Solved: Excel 2007 Pivot Table

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

computerman29642

Thread Starter
Joined
Dec 4, 2007
Messages
2,895
I have created a pivot table within an Excel 2007 workbook.

I am trying to apply the following code to the pivot table:

Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

    Application.ScreenUpdating = False
    
    Dim LastRow As Long, iRow As Long

Set ws2 = ActiveWorkbook.Sheets("Pivot")
    
    With ws2.Range("A2:B" & ws2.Rows.Count)
        LastRow = .Find(What:="*", after:=.Cells(1, 1), LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    End With
    
    iRow = LastRow

        ws2.Range("A3:B" & iRow).Borders(xlDiagonalDown).LineStyle = xlNone
        ws2.Range("A3:B" & iRow).Borders(xlDiagonalUp).LineStyle = xlNone
        ws2.Range("A3:B" & iRow).Borders(xlEdgeLeft).LineStyle = xlContinuous
        ws2.Range("A3:B" & iRow).Borders(xlEdgeLeft).Weight = xlThin
        ws2.Range("A3:B" & iRow).Borders(xlEdgeLeft).ColorIndex = xlAutomatic
        ws2.Range("A3:B" & iRow).Borders(xlEdgeTop).LineStyle = xlContinuous
        ws2.Range("A3:B" & iRow).Borders(xlEdgeTop).Weight = xlThin
        ws2.Range("A3:B" & iRow).Borders(xlEdgeTop).ColorIndex = xlAutomatic
        ws2.Range("A3:B" & iRow).Borders(xlEdgeBottom).LineStyle = xlContinuous
        ws2.Range("A3:B" & iRow).Borders(xlEdgeBottom).Weight = xlThin
        ws2.Range("A3:B" & iRow).Borders(xlEdgeBottom).ColorIndex = xlAutomatic
        ws2.Range("A3:B" & iRow).Borders(xlEdgeRight).LineStyle = xlContinuous
        ws2.Range("A3:B" & iRow).Borders(xlEdgeRight).Weight = xlThin
        ws2.Range("A3:B" & iRow).Borders(xlEdgeRight).ColorIndex = xlAutomatic
        ws2.Range("A3:B" & iRow).Borders(xlInsideVertical).LineStyle = xlContinuous
        ws2.Range("A3:B" & iRow).Borders(xlInsideVertical).Weight = xlThin
        ws2.Range("A3:B" & iRow).Borders(xlInsideVertical).ColorIndex = xlAutomatic
        ws2.Range("A3:B" & iRow).Borders(xlInsideHorizontal).LineStyle = xlContinuous
        ws2.Range("A3:B" & iRow).Borders(xlInsideHorizontal).Weight = xlThin
        ws2.Range("A3:B" & iRow).Borders(xlInsideHorizontal).ColorIndex = xlAutomatic

Application.ScreenUpdating = False
end sub
However, I get the following error:

Run-time error '1004': Unable to set the LineStyle property of the border class.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top