Friday, November 9, 2012

Shortcut keys

Ctrl+Z

Undo

Ctrl+C

Ctrl+V
Ctrl+X

Copy,

Paste & Multiple Paste

Cut

Ctrl+F,
Ctrl+H

Find,
Find&Replace

Ctrl+P,
Ctrl+S, Ctrl+F4,

Ctrl+F4

Alt+F4

Print,
Save, Close,
Close
Excel

Ctrl+Arrow

Move to edge of region

Ctrl+*

Select
current region

Ctrl+A

Select all cells

Ctrl+Home
Ctrl+End

Select A1,
Select last cell in used range

Ctrl+Shift+End

Select from active cell to last cell in used range.

Ctrl+Shift+Home

Select from active cell to A1

Ctrl+Page Down
Ctrl+Page Up

Move to the next sheet,
Move to the previous sheet

Ctrl+Tab

Move to next open workbook

Ctrl+N

Open new workbook

Shift+F11

Insert new worksheet

Shift+F3

Paste function window

=+FunctionName+Ctrl+A

Insert new function

Alt+F11

Open VBE

Ctrl+Shift+Enter

Array formula

Ctrl+F3,
F3

Define name, Paste name

Ctrl+Spacebar
Shift+Spacebar

Select columns,

Select rows

Ctrl+1,
Ctrl+B, Ctrl+U

Format
cells, Bold, Underline

Ctrl+;
, Ctrl+shift+:

Current
date, Current time

Convert PowerPoint Presentation PPT to PDF


How to Convert PowerPoint Presentation PPT to PDF using VBA

PDF is always the universal format for sending the files. With lot of versions of MS Office and other Office suites around.
The following snippet converts the Presentation to a PDF and saves in the same folder of the PPT

ActivePresentation.ExportAsFixedFormat ActivePresentation.Path & "\" & ActivePresentation.Name & ".pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint
'Get the name of the currently active file. You'll need this when
'toggelinig between two files, and you want to open the old file
'where the data is assembled

Dim OrginialFile
OriginalFile = Application.ActiveWorkbook.Name

'Open new file
Dim MyFile
MyFile = "C:Maria\Myfolder\Myfile.xls"
Workbooks.Open FileName:=MyFile

'Close a file
Dim MyNewFile

MyNewFile = "MyWonderfulFile.xls"

'Unable ScreenUpdating and DisoplayAlerts, so teh user isn't asked if he want tosave the changes

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Windows(MyNewFile).Close
Application.ScreenUpdating = true
Application.DisplayAlerts = true


'Toggle between open files.

Dim AnotherOpenFile
AnotherOpenFile = "MyWounderfullFile.xls"
Windows(AnotherOpenFile ).Activate

DeletePivotTables

Sub DeletePivotTables()

Dim Pt As PivotTable
Dim Ws As Worksheet

'Loop through worksheets
For Each Ws In ActiveWorkbook.Worksheets
Worksheets(Ws.Name).Select
'Loop through pivot tables

For Each Pt In Ws.PivotTables
'Delete pivot table

Pt.PivotSelect "", xlDataAndLabel, True
Selection.Delete Shift:=xlToLeft
'Exit Sub 'Optional: Get out
Next Pt
Next Ws
End Sub

Check Extension


Sub CheckExtn()

Dim MinExtensionX
Dim Arr() As Variant
Dim lngLoc As Variant

'Retrieve extension of file
MinExtensionX = Mid(MyFile.Name, InStrRev(MyFile.Name, ".") + 1)

Arr = Array("xls", "xlsx") 'define which extensions you want to allow

On Error Resume Next

lngLoc = Application.WorksheetFunction.Match(MinExtensionX, Arr(), 0)

If Not IsEmpty(lngLoc) Then '

'DO STUFF if it's an xls/xlsx file. Otherwise, chose next file in folder

End If