Created
August 4, 2016 14:35
-
-
Save echristopherson/7bf22e4a1e8eaf1e31ac89ae37bbded1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub PasteFormulas() | |
' | |
' PasteFormulas Macro | |
' Paste formulas, retaining destination formatting | |
' | |
' | |
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ | |
SkipBlanks:=False, Transpose:=False | |
End Sub | |
Sub ShowAllDependents() | |
' ShowAllDependents Macro | |
' Show dependents on all cells in range | |
For Each c In Selection | |
c.Select | |
Selection.ShowDependents | |
Next | |
End Sub | |
' In monthly report spreadsheet, hide all columns EXCEPT columns A and B (legends) and the last 13 columns that have values in their row 1 cell (month names). | |
Sub HideMonthlyReportColumns() | |
latestShownMonthColumn = Range("B1").End(xlToRight).Column ' there's nothing in A1, so xlToRight would move from there to B1 | |
earliestShownMonthColumn = latestShownMonthColumn - 12 | |
Worksheets("Summary").Range(Columns(3), Columns(earliestShownMonthColumn - 1)).Hidden = True | |
End Sub | |
' In monthly report spreadsheet, show all columns. | |
Sub ShowAllMonthlyReportColumns() | |
Worksheets("Summary").Range(Columns(1), Columns(Columns.Count)).Hidden = False | |
End Sub | |
Sub SaveAsWorkbook(current_document_path) | |
' NOTE: This isn't a perfect variable name -- it's only the path minus the extension. Excel adds the extension automatically. | |
new_document_path = Left(current_document_path, (InStrRev(current_document_path, ".", -1, vbTextCompare) - 1)) | |
ActiveWorkbook.SaveAs Filename:=new_document_path, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False | |
End Sub | |
Sub SaveAsWorkbookKeepingOriginal() | |
current_document_path = ActiveWorkbook.FullName | |
SaveAsWorkbook current_document_path | |
End Sub | |
Sub SaveAsWorkbookDeletingOriginal() | |
current_document_path = ActiveWorkbook.FullName | |
SaveAsWorkbook current_document_path | |
Kill current_document_path | |
End Sub | |
Sub SaveAsText(current_document_path) | |
' NOTE: This isn't a perfect variable name -- it's only the path minus the extension. Excel adds the extension automatically. | |
new_document_path = Left(current_document_path, (InStrRev(current_document_path, ".", -1, vbTextCompare) - 1)) | |
ActiveWorkbook.SaveAs Filename:=new_document_path, FileFormat:=xlTextWindows, CreateBackup:=False | |
End Sub | |
Sub SaveAsTextKeepingOriginal() | |
current_document_path = ActiveWorkbook.FullName | |
SaveAsText current_document_path | |
End Sub | |
Sub SaveAsTextDeletingOriginal() | |
current_document_path = ActiveWorkbook.FullName | |
SaveAsText current_document_path | |
Kill current_document_path | |
End Sub | |
Sub SaveAsCSV(current_document_path) | |
' NOTE: This isn't a perfect variable name -- it's only the path minus the extension. Excel adds the extension automatically. | |
new_document_path = Left(current_document_path, (InStrRev(current_document_path, ".", -1, vbTextCompare) - 1)) | |
ActiveWorkbook.SaveAs Filename:=new_document_path, FileFormat:=xlCSVWindows, CreateBackup:=False | |
End Sub | |
Sub SaveAsCSVKeepingOriginal() | |
current_document_path = ActiveWorkbook.FullName | |
SaveAsCSV current_document_path | |
End Sub | |
Sub SaveAsCSVDeletingOriginal() | |
current_document_path = ActiveWorkbook.FullName | |
SaveAsCSV current_document_path | |
Kill current_document_path | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment