I've created a VBA macro to take data from a sharepoint list and convert it into a format where i'm able to utilise a pivot table to display the data.
The macro itself runs fine albeit a little slow and was wondering if anyone could help me perform some performance tuning, i'm not looking for someone to do it for me just a few pointers of what i should be looking at as i'll prefer to learn
Explanation:
Data is pulled through into 4 sheets (Iplus, RI, Docs, Compliance) via 4 workbook connections and automatically refreshes on open.
The macro then works through the 4 sheets transposing the data into a sheet called "other combined data" and adds a selection of vlookups to add some additional data (also from another sheet)
Other combined data is then used as the base for a number of pivot tables that allows the user to interrogate and manipulate the data how they see fit.
TIA Kipo
The macro itself runs fine albeit a little slow and was wondering if anyone could help me perform some performance tuning, i'm not looking for someone to do it for me just a few pointers of what i should be looking at as i'll prefer to learn

Explanation:
Data is pulled through into 4 sheets (Iplus, RI, Docs, Compliance) via 4 workbook connections and automatically refreshes on open.
The macro then works through the 4 sheets transposing the data into a sheet called "other combined data" and adds a selection of vlookups to add some additional data (also from another sheet)
Other combined data is then used as the base for a number of pivot tables that allows the user to interrogate and manipulate the data how they see fit.
Code:
Sub ReversePivotTable()
Dim SummaryTable As Range, OutputRange As Range
Dim OutRow As Long
Dim r As Long, c As Long
Dim strBar As String
Dim lngLoop As Long
On Error Resume Next
With Sheets("Other Combined Data").Cells
.Select
.ClearContents
End With
Application.DisplayStatusBar = True
Application.Calculation = xlCalculateManual
Set SummaryTable = Sheets("Iplus").Range("A1").CurrentRegion
SummaryTable.Select
Set OutputRange = Sheets("Other Combined Data").Range("A1")
OutRow = 2
Application.StatusBar = String(2, ChrW(9609)) & "Working..."
Application.ScreenUpdating = False
OutputRange.Range("A1:U1") = Array("Policy", "Field", "Data", "Area", "Channel", "Month", "Name of Underwriter", "Auditor", "Type of Audit", "Product", "Unoccupied", "Transaction Type", "Category", "Result", "Year", "Quarter", "Hotspot", "Month2", "Policy Branch", "Category2", "Overall Result")
For r = 2 To SummaryTable.Rows.Count
For c = 2 To SummaryTable.Columns.Count
OutputRange.Cells(OutRow, 1) = SummaryTable.Cells(r, 1)
OutputRange.Cells(OutRow, 2) = SummaryTable.Cells(1, c)
OutputRange.Cells(OutRow, 3).Value = SummaryTable.Cells(r, c).Value
Select Case OutputRange.Cells(OutRow, 3)
Case "0"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "00:00:00"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "1"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "2"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "5"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "01/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "02/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "05/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
End Select
'OutputRange.Cells(OutRow, 3).NumberFormat = SummaryTable.Cells(r, c).NumberFormat
OutputRange.Cells(OutRow, 4) = "=VLOOKUP(RC[-3],Combined_Items,2,FALSE)" 'area
OutputRange.Cells(OutRow, 5) = "=VLOOKUP(RC[-4],Combined_Items,3,FALSE)" 'channel
OutputRange.Cells(OutRow, 6) = "=VLOOKUP(RC[-5],Combined_Items,6,FALSE)" 'month
OutputRange.Cells(OutRow, 7) = "=VLOOKUP(RC[-6],Combined_Items,11,FALSE)" 'name of underwriter
OutputRange.Cells(OutRow, 8) = "=VLOOKUP(RC[-7],Combined_Items,10,FALSE)" 'auditor
OutputRange.Cells(OutRow, 9) = "=VLOOKUP(RC[-8],Combined_Items,14,FALSE)" 'type of audit
OutputRange.Cells(OutRow, 10) = "=VLOOKUP(RC[-9],Combined_Items,15,FALSE)" 'product
OutputRange.Cells(OutRow, 11) = "=VLOOKUP(RC[-10],Combined_Items,16,FALSE)" 'unoccupied
OutputRange.Cells(OutRow, 12) = "=VLOOKUP(RC[-11],Combined_Items,17,FALSE)" 'Transaction Type
OutputRange.Cells(OutRow, 13) = "IPlus" 'Category
OutputRange.Cells(OutRow, 14) = "=VLOOKUP(RC[-13],Combined_Items,19,FALSE)" 'Result
OutputRange.Cells(OutRow, 15) = "=VLOOKUP(RC[-14],Combined_Items,7,FALSE)" 'year
OutputRange.Cells(OutRow, 16) = "=VLOOKUP(RC[-15],Combined_Items,8,FALSE)" 'quarter
OutputRange.Cells(OutRow, 17) = "=VLOOKUP(RC[-16],Combined_Items,5,FALSE)" 'hotspot
OutputRange.Cells(OutRow, 18) = "=VLOOKUP(RC[-17],Combined_Items,20,FALSE)" 'month2
OutputRange.Cells(OutRow, 19) = "=VLOOKUP(RC[-18],Combined_Items,12,FALSE)" 'policy branch
OutputRange.Cells(OutRow, 20) = "IPlus" 'category2
OutputRange.Cells(OutRow, 21) = "=VLOOKUP(RC[-20],Combined_Items,25,FALSE)"
OutRow = OutRow + 1
Next c
Next r
Application.ScreenUpdating = True
Application.StatusBar = String(4, ChrW(9609)) & "Still Working..."
Application.ScreenUpdating = False
Set SummaryTable = Sheets("Compliance").Range("A1").CurrentRegion
SummaryTable.Select
Set OutputRange = Sheets("Other Combined Data").Range("A1")
For r = 2 To SummaryTable.Rows.Count
For c = 25 To SummaryTable.Columns.Count
OutputRange.Cells(OutRow, 1) = SummaryTable.Cells(r, 1)
OutputRange.Cells(OutRow, 2) = SummaryTable.Cells(1, c)
OutputRange.Cells(OutRow, 3).Value = SummaryTable.Cells(r, c).Value
Select Case OutputRange.Cells(OutRow, 3)
Case "0"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "00:00:00"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "1"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "2"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "5"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "01/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "02/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "05/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
End Select
'OutputRange.Cells(OutRow, 3).NumberFormat = SummaryTable.Cells(r, c).NumberFormat
OutputRange.Cells(OutRow, 4) = "=VLOOKUP(RC[-3],Combined_Items,2,FALSE)" 'area
OutputRange.Cells(OutRow, 5) = "=VLOOKUP(RC[-4],Combined_Items,3,FALSE)" 'channel
OutputRange.Cells(OutRow, 6) = "=VLOOKUP(RC[-5],Combined_Items,6,FALSE)" 'month
OutputRange.Cells(OutRow, 7) = "=VLOOKUP(RC[-6],Combined_Items,11,FALSE)" 'name of underwriter
OutputRange.Cells(OutRow, 8) = "=VLOOKUP(RC[-7],Combined_Items,10,FALSE)" 'auditor
OutputRange.Cells(OutRow, 9) = "=VLOOKUP(RC[-8],Combined_Items,14,FALSE)" 'type of audit
OutputRange.Cells(OutRow, 10) = "=VLOOKUP(RC[-9],Combined_Items,15,FALSE)" 'product
OutputRange.Cells(OutRow, 11) = "=VLOOKUP(RC[-10],Combined_Items,16,FALSE)" 'unoccupied
OutputRange.Cells(OutRow, 12) = "=VLOOKUP(RC[-11],Combined_Items,17,FALSE)" 'Transaction Type
OutputRange.Cells(OutRow, 13) = "Compliance" 'Category
OutputRange.Cells(OutRow, 14) = "=VLOOKUP(RC[-13],Combined_Items,19,FALSE)" 'Result
OutputRange.Cells(OutRow, 15) = "=VLOOKUP(RC[-14],Combined_Items,7,FALSE)" 'year
OutputRange.Cells(OutRow, 16) = "=VLOOKUP(RC[-15],Combined_Items,8,FALSE)" 'quarter
OutputRange.Cells(OutRow, 17) = "=VLOOKUP(RC[-16],Combined_Items,5,FALSE)" 'hotspot
OutputRange.Cells(OutRow, 18) = "=VLOOKUP(RC[-17],Combined_Items,20,FALSE)" 'month2
OutputRange.Cells(OutRow, 19) = "=VLOOKUP(RC[-18],Combined_Items,12,FALSE)" 'policy branch
OutputRange.Cells(OutRow, 20) = "Compliance" 'category2
OutputRange.Cells(OutRow, 21) = "=VLOOKUP(RC[-20],Combined_Items,25,FALSE)"
OutRow = OutRow + 1
Next c
Next r
Application.ScreenUpdating = True
Application.StatusBar = String(6, ChrW(9609)) & "Still Working..."
Application.ScreenUpdating = False
Set SummaryTable = Sheets("Docs").Range("A1").CurrentRegion
SummaryTable.Select
Set OutputRange = Sheets("Other Combined Data").Range("A1")
For r = 2 To SummaryTable.Rows.Count
For c = 25 To SummaryTable.Columns.Count
OutputRange.Cells(OutRow, 1) = SummaryTable.Cells(r, 1)
OutputRange.Cells(OutRow, 2) = SummaryTable.Cells(1, c)
OutputRange.Cells(OutRow, 3).Value = SummaryTable.Cells(r, c).Value
Select Case OutputRange.Cells(OutRow, 3)
Case "0"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "00:00:00"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "1"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "2"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "5"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "01/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "02/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "05/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
End Select
'OutputRange.Cells(OutRow, 3).NumberFormat = SummaryTable.Cells(r, c).NumberFormat
OutputRange.Cells(OutRow, 4) = "=VLOOKUP(RC[-3],Combined_Items,2,FALSE)" 'area
OutputRange.Cells(OutRow, 5) = "=VLOOKUP(RC[-4],Combined_Items,3,FALSE)" 'channel
OutputRange.Cells(OutRow, 6) = "=VLOOKUP(RC[-5],Combined_Items,6,FALSE)" 'month
OutputRange.Cells(OutRow, 7) = "=VLOOKUP(RC[-6],Combined_Items,11,FALSE)" 'name of underwriter
OutputRange.Cells(OutRow, 8) = "=VLOOKUP(RC[-7],Combined_Items,10,FALSE)" 'auditor
OutputRange.Cells(OutRow, 9) = "=VLOOKUP(RC[-8],Combined_Items,14,FALSE)" 'type of audit
OutputRange.Cells(OutRow, 10) = "=VLOOKUP(RC[-9],Combined_Items,15,FALSE)" 'product
OutputRange.Cells(OutRow, 11) = "=VLOOKUP(RC[-10],Combined_Items,16,FALSE)" 'unoccupied
OutputRange.Cells(OutRow, 12) = "=VLOOKUP(RC[-11],Combined_Items,17,FALSE)" 'Transaction Type
OutputRange.Cells(OutRow, 13) = "Docs" 'Category
OutputRange.Cells(OutRow, 14) = "=VLOOKUP(RC[-13],Combined_Items,19,FALSE)" 'Result
OutputRange.Cells(OutRow, 15) = "=VLOOKUP(RC[-14],Combined_Items,7,FALSE)" 'year
OutputRange.Cells(OutRow, 16) = "=VLOOKUP(RC[-15],Combined_Items,8,FALSE)" 'quarter
OutputRange.Cells(OutRow, 17) = "=VLOOKUP(RC[-16],Combined_Items,5,FALSE)" 'hotspot
OutputRange.Cells(OutRow, 18) = "=VLOOKUP(RC[-17],Combined_Items,20,FALSE)" 'month2
OutputRange.Cells(OutRow, 19) = "=VLOOKUP(RC[-18],Combined_Items,12,FALSE)" 'policy branch
OutputRange.Cells(OutRow, 20) = "Docs" 'category2
OutputRange.Cells(OutRow, 21) = "=VLOOKUP(RC[-20],Combined_Items,25,FALSE)"
OutRow = OutRow + 1
Next c
Next r
Application.ScreenUpdating = True
Application.StatusBar = String(8, ChrW(9609)) & "Still Working..."
Application.ScreenUpdating = False
Set SummaryTable = Sheets("RI").Range("A1").CurrentRegion
SummaryTable.Select
Set OutputRange = Sheets("Other Combined Data").Range("A1")
For r = 2 To SummaryTable.Rows.Count
For c = 25 To SummaryTable.Columns.Count
OutputRange.Cells(OutRow, 1) = SummaryTable.Cells(r, 1)
OutputRange.Cells(OutRow, 2) = SummaryTable.Cells(1, c)
OutputRange.Cells(OutRow, 3).Value = SummaryTable.Cells(r, c).Value
Select Case OutputRange.Cells(OutRow, 3)
Case "0"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "00:00:00"
OutputRange.Cells(OutRow, 3) = vbNullString
Case "1"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "2"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "5"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "01/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "02/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "05/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
Case "11/01/1900"
OutputRange.Cells(OutRow, 3) = CInt(OutputRange.Cells(OutRow, 3))
End Select 'OutputRange.Cells(OutRow, 3).NumberFormat = SummaryTable.Cells(r, c).NumberFormat
OutputRange.Cells(OutRow, 4) = "=VLOOKUP(RC[-3],Combined_Items,2,FALSE)" 'area
OutputRange.Cells(OutRow, 5) = Format("=VLOOKUP(RC[-4],Combined_Items,3,FALSE)", "General Number") 'channel
OutputRange.Cells(OutRow, 6) = "=VLOOKUP(RC[-5],Combined_Items,6,FALSE)" 'month
OutputRange.Cells(OutRow, 7) = "=VLOOKUP(RC[-6],Combined_Items,11,FALSE)" 'name of underwriter
OutputRange.Cells(OutRow, 8) = "=VLOOKUP(RC[-7],Combined_Items,10,FALSE)" 'auditor
OutputRange.Cells(OutRow, 9) = "=VLOOKUP(RC[-8],Combined_Items,14,FALSE)" 'type of audit
OutputRange.Cells(OutRow, 10) = "=VLOOKUP(RC[-9],Combined_Items,15,FALSE)" 'product
OutputRange.Cells(OutRow, 11) = "=VLOOKUP(RC[-10],Combined_Items,16,FALSE)" 'unoccupied
OutputRange.Cells(OutRow, 12) = "=VLOOKUP(RC[-11],Combined_Items,17,FALSE)" 'Transaction Type
OutputRange.Cells(OutRow, 13) = "RI" 'Category
OutputRange.Cells(OutRow, 14) = "=VLOOKUP(RC[-13],Combined_Items,19,FALSE)" 'Result
OutputRange.Cells(OutRow, 15) = "=VLOOKUP(RC[-14],Combined_Items,7,FALSE)" 'year
OutputRange.Cells(OutRow, 16) = "=VLOOKUP(RC[-15],Combined_Items,8,FALSE)" 'quarter
OutputRange.Cells(OutRow, 17) = "=VLOOKUP(RC[-16],Combined_Items,5,FALSE)" 'hotspot
OutputRange.Cells(OutRow, 18) = "=VLOOKUP(RC[-17],Combined_Items,20,FALSE)" 'month2
OutputRange.Cells(OutRow, 19) = "=VLOOKUP(RC[-18],Combined_Items,12,FALSE)" 'policy branch
OutputRange.Cells(OutRow, 20) = "RI" 'category2
OutputRange.Cells(OutRow, 21) = "=VLOOKUP(RC[-20],Combined_Items,25,FALSE)"
OutRow = OutRow + 1
Next c
Next r
Application.ScreenUpdating = True
Application.StatusBar = String(10, ChrW(9609)) & "Almost Done..."
Application.ScreenUpdating = False
Application.StatusBar = False
'Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
TIA Kipo
