Hi,
I'm trying to format cells in a worksheet so that for all columns from col B and row 3 downwards the cells only show decimals as required (max 2 decimal places) e.g.
12
12.1
12.12
Column A and rows 1 and 2 are text and dates so don't need the format.
I've found the below code but it's not doing quite what I want, can anyone suggest any tweaks to make it fit my needs?
I'm trying to format cells in a worksheet so that for all columns from col B and row 3 downwards the cells only show decimals as required (max 2 decimal places) e.g.
12
12.1
12.12
Column A and rows 1 and 2 are text and dates so don't need the format.
I've found the below code but it's not doing quite what I want, can anyone suggest any tweaks to make it fit my needs?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Intersect(Target, Columns("C"))
If Not Cell.Value Like "*[!0-9]*" Then
Cell.NumberFormat = "General"
ElseIf Not Cell.Value Like "*[!0-9.]*" And Not Cell.Value Like "*.*.*" Then
Cell.NumberFormat = "0.00"
Else
Cell.NumberFormat = "General"
End If
Next
End Sub