Macro to create Pivot Table

Macro to create Pivot Table from a data set

Sub CreatePivotTable()
Dim SourceRange As Range
Set SourceRange = ActiveCell.CurrentRegion
ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=SourceRange, _
Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="", _
TableName:="", DefaultVersion:=xlPivotTableVersion15
End Sub

Macro to refresh all Pivot Tables in a workbook

Sub RefreshPivotTable()
Dim PT As PivotTable
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
For Each PT In WS.PivotTables
Next PT
Next WS
End Sub

How to use codes shared here?