Skip to content

Instantly share code, notes, and snippets.

@ateneva
ateneva / PT_CreatePivotTable.bas
Last active April 22, 2017 13:44
Create, populate and format a pivot table at the click of a button!
Sub SummarizeCampaignData()
Dim Wks As Worksheet
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim PF As PivotField
Dim i As Integer
Dim Title As String
Dim Field As String
'~~~~~~~~~~~~~~~~~~~~~~~~
@ateneva
ateneva / ForEachPT_AddShowPTCalculatedFields.bas
Last active April 22, 2017 13:44
Add calculated fields and make them visible in all pivot tables in the workbook
Sub AddAndShowPTCalculatedFields()
Dim Wks As Worksheet
Dim PT As PivotTable
Dim PF As PivotField
Dim PI As PivotItem
Dim Title As String
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each Wks In ActiveWorkbook.Worksheets
@ateneva
ateneva / ForEachPT_ModifyDataFieldsSummaryFunctions.bas
Last active April 22, 2017 13:42
Modify the summary functions for each pivot table in your workbook
Sub ModifyDataFieldsSummaryFunction()
Dim PT As PivotTable
Dim PF As PivotField
Dim PI As PivotItem
Dim i As Integer
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, 2014
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ateneva
ateneva / ForEachPT_ExportToOpenPPT.bas
Last active April 22, 2017 16:41
Export each pivot table from a worksheet to an open PowerPoint presentation
Sub Export_PPT_Internal()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Angelina Teneva, Aug 2014
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Sh As Shape
Dim PT As PivotTable
Dim PL As String
Dim PPApp As PowerPoint.Application
Set PPApp = GetObject(, "Powerpoint.Application") 'use if you are planning on having your ppt open
@ateneva
ateneva / ForEachPT_ExportToClosedPPT.bas
Last active March 18, 2018 12:56
Export each pivot table in a worksheet to a closed presentation
Sub ExcelToPowerPoint_Open()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Angelina Teneva, Aug 2014
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Sh As Shape
Dim PPApp As PowerPoint.Application
Dim PPpres As PowerPoint.Presentation
Dim PPS As Integer
Dim Wks As Worksheet
@ateneva
ateneva / ForEachPT_ExportUtil.bas
Last active April 22, 2017 19:43
Re-filter a pivot table and export the views to PowerPoint
Sub Utilization()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, 2013
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Application.Calculation = xlCalculationAutomatic
Dim PT As PivotTable
Dim PF As PivotField
Dim PI As PivotItem
Dim L As String
@ateneva
ateneva / ForEachCell_ExportCameraPicToPPT.bas
Last active April 23, 2017 11:29
Re-filter and export your camera pic to PowerPoint slides
Sub Select_Actual()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, 2014
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Msg As Integer, Ans As Integer
Dim Sh As Shape
Dim PPApp As PowerPoint.Application
Dim PPpres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
@ateneva
ateneva / ForEachChtInWbk_ExportToPPT.bas
Last active April 23, 2017 11:28
Export all the chartsheets from the currently active workbook to PowerPoint
Sub ExportFSCSlides()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, 2015
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim PPApp As PowerPoint.Application
Dim PPpres As PowerPoint.Presentation
Dim pptx As String
pptx = ActiveWorkbook.Worksheets("calculated fields").Range("F2")
@ateneva
ateneva / ForEachChtObjInWbk_ExportToPPT.bas
Last active August 15, 2018 20:40
Export interactive chart embedded on a worksheet to PowerPoint
Sub ExportFSCSlides()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, 2015
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim PPApp As PowerPoint.Application
Dim PPpres As PowerPoint.Presentation
Dim pptx As String
pptx = ActiveWorkbook.Worksheets("calculated fields").Range("F2")
@ateneva
ateneva / SQL_date_standard_functions.sql
Last active December 31, 2017 16:16
How to extract part of a date in SQL
---------------------------Vertica----------------------------------------------------------------------------
select
Now(), ---find current timestamp
Date(Now()), ---find today's date
Year(Now()), ---find today's year
Quarter(Now()), ---find today's quarter
Month(Now()), ---find today's month