Skip to content

Instantly share code, notes, and snippets.

@ateneva
ateneva / ForEachShOnSlide_Delete_All_but_Title.bas
Created August 2, 2018 12:18
How do I delete all of a slide content but its title with VBA?
Sub Delete_All_but_Title()
Dim p As Presentation
Set p = ActivePresentation
Dim PPS As Slide
'***************************
For Each PPS In p.Slides
Dim i As Shape
@ateneva
ateneva / ForEachSInSlides_Delete_Slides_TextinTitle.bas
Created August 2, 2018 12:13
How do I automatically delete slides based on the content of their header?
Sub Delete_Slides_TextinTitle()
Dim Ppres As Presentation
Set Ppres = ActivePresentation
Dim PPS As Slide
Dim StrNo As Long
Dim Titel As String
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each PPS In Ppres.Slides
@ateneva
ateneva / ForEachSInSlides_Delete_Slides_other_criteria.bas
Created August 2, 2018 12:11
How do I delete slides based on their layout or content?
Sub Delete_Slides_other_criteria()
Dim p As Presentation
Set p = ActivePresentation
Dim Sh As Shape
Dim PPS As Slide
Dim i As Integer
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ateneva
ateneva / ForEachSInSlides_Delete_Slides_on_SlideIDs.bas
Last active August 2, 2018 12:11
How do I only delete certain slides in a presentation?
Sub Delete_Slides_on_SlideIDs()
Dim Ppres As Presentation
Set Ppres = ActivePresentation
Dim Sh As Shape
Dim i As Integer
Dim PPS As Slide
'******************************************************
'used in Delivery Reviews
@ateneva
ateneva / LinearRegression.py
Last active July 31, 2018 13:23
How do I run linear regression with Python?
import pandas as pd
import numpy as np
import statsmodels
import statsmodels.api as sm
import statsmodels.formula.api as smf
import os;
path ='C:/Users/hp/PycharmProjects/datascience/'
os.chdir(path)
os.getcwd()
@ateneva
ateneva / PPT.bas
Last active August 2, 2018 11:29
How do I quickly save a presentation under a new name and file extension?
Sub S()
Dim Ppres As Presentation
Set Ppres = ActivePresentation
Dim location As String
'~~~~~~~~~~~~saving in a location specified by us~~~~~~~~~~~~~~~~~~~~~
location = "C:\Users\Angelina\Review\MonthlyReview.pptx"
Ppres.SaveAs FileName:=location, FileFormat:=ppSaveAsDefault
@ateneva
ateneva / SlideinSlides.bas
Created July 25, 2018 23:08
How do I quickly compile a single PowerPoint presentation from slides saved in multiple files?
Option Explicit
Sub Update_Slide_Data()
Dim Ppres As Presentation
Set Ppres = Presentations("C:\Users\Angelina\Documents\2015_Review.pptm")
Dim location As String
location = "C:\Users\Angelina\Documents\2013_Review.pptx"
Dim PPS As PowerPoint.Slide
@ateneva
ateneva / CellinR_ModifyCellInput.bas
Created July 22, 2018 21:44
How do I quickly add extra characters to a cell?
Sub AddJIRATableBars()
Dim Cell As Range
Dim oldvalue As String
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each Cell In ActiveSheet.Range("A1:H" & ActiveSheet.UsedRange.Rows.Count)
On Error Resume Next
oldvalue = Cell.Value
@ateneva
ateneva / ShowWbkPaths.bas
Last active July 22, 2018 00:20
How do I incorporate my workbook path in my VBA?
Sub ShowUser()
ActiveCell.Value = Environ("UserName") 'returns the domain name
ActiveCell.Offset(1, 0).Value = Application.UserName 'the user registered name
ActiveCell.Offset(2, 0).Value = Application.UserLibraryPath 'location where COM-Addins are installed
ActiveCell.Offset(3, 0).Value = "C:\Users\" & UCase(Environ("UserName")) & "\Desktop" 'returns a custom directory
ActiveCell.Offset(4, 0).Value = ActiveWorkbook.FullName 'the path + the name of the file <-- assimes file has been saved
ActiveCell.Offset(5, 0).Value = ActiveWorkbook.name 'returns the name of the file alone
ActiveCell.Offset(6, 0).Value = ActiveWorkbook.path 'returns the path where it is saved
ActiveCell.Offset(7, 0).Value = Application.PathSeparator 'returns the dash
@ateneva
ateneva / CellinR_ModifyValues.bas
Created July 21, 2018 21:56
How do I quickly re-map values with VBA?
Sub ReplaceConstantValues()
Dim Cell As Range
For Each Cell In ActiveSheet.Range("E2:E" & ActiveSheet.UsedRange.Rows.Count).SpecialCells(xlCellTypeVisible)
Cell.Replace " USA", "USA"
If Cell.Value = "Nederland" Then Cell.Value = "Netherlands"
If Cell.Value = "Luxemburg" Then Cell.Value = "Luxembourg"