Private Sub ApplyFormats()
Dim x As Long, I As Long, formats As Collection
Dim header As String, currentCol As Long
Dim row As Long
Set formats = New Collection
With formats
.Add "$#,###.00", "Price"
End With
With MSHFlexGrid1
currentCol = 0
.Redraw = False
For I = 0 To .Bands - 1
For x = 0 To .Cols(I) - 1
header = .ColHeaderCaption(I, x)
If Len(header) Then
'Set formats
On Error Resume Next
Dim vFormat As Variant
vFormat = CStr(formats(header))
On Error GoTo 0
If Not IsEmpty(vFormat) Then
For row = .FixedRows To .Rows - 1
If Len(.TextMatrix(row, currentCol)) Then
TextMatrix(row, currentCol) = _
Format(Val(.TextMatrix(row, currentCol)), vFormat)
End If
Next row
End If
End If
currentCol = currentCol + 1
Next x
Next I
.Redraw = True
End With
Set formats = Nothing
End Sub