Skip to content

Instantly share code, notes, and snippets.

@enkelmedia
Last active October 2, 2017 14:44
Show Gist options
  • Save enkelmedia/5445af2d577c0c803b8faee78a9bf211 to your computer and use it in GitHub Desktop.
Save enkelmedia/5445af2d577c0c803b8faee78a9bf211 to your computer and use it in GitHub Desktop.
Sub NumericFormatting()
'
' NumericFormatting Macro
'
' Keyboard Shortcut: Ctrl+Shift+N
'
Dim cel As Range
Dim selectedRange As Range
Set selectedRange = Application.Selection
For Each cel In selectedRange.Cells
If Not cel.HasFormula Then
cel.Value = Replace(cel.Text, " ", "")
cel.Value = Replace(cel.Text, " ", "")
cel.Value = CSng(cel.Value)
End If
cel.NumberFormat = "#,##0"
Next cel
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment