Last active
November 18, 2016 02:03
-
-
Save vicro/f0ebe5d77ca0550aee306ac470537237 to your computer and use it in GitHub Desktop.
Quick ref for Excel Macros
This file contains 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
' ------------------------------------------------------------------------------ | |
' Quick ref for Excel Macros | |
' ------------------------------------------------------------------------------ | |
' for loops | |
Dim i as Integer | |
For i = 0 To 10 | |
' Basic ranged loop | |
Next i | |
' ------------------------------------------------------------------------------ | |
' Handy functions | |
' ------------------------------------------------------------------------------ | |
' from: http://www.mrexcel.com/forum/excel-questions/508248-excel-2007-remove-all-custom-styles.html | |
' Delete all non built in styles from workbook | |
Public Sub CleanupStyles() | |
Dim sty As Style | |
For Each sty In ActiveWorkbook.Styles | |
If Not sty.BuiltIn Then | |
' Ignore some by name | |
If sty.Name <> "column_info" And sty.Name <> "Sheet Title" Then | |
'Delete the style | |
sty.Delete | |
End If | |
End If | |
Next sty | |
End Sub | |
' Copies comments from all selected cells in to the cell below it | |
Sub copyComments() | |
Dim source_range As Range | |
Set source_range = Selection | |
Dim cell As Range | |
For Each cell In source_range | |
txt = cell.Comment.Text | |
cell.Offset(1,0).Value = txt | |
Next cell | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment