Dear Forum,
I am trying to do this but am getting an error and I am no an expert in VBA but trying after ging through some of my past threads where I have received help..
Please correct me and advise whats the mistake in the below mentioned code.
Option Explicit
Sub Trial()
With Sheets("TRY")
Dim rngSingleColumn As Range
Set rngSingleColumn = Range(.Cells(2, 2), .Cells(6, 2))
Swap_NumberFormat rngSingleColumn
End With
End Sub
The below Sub is called in the above Sub which is just a Trial, the actual Sub will be in the WorkSheet_Change event..
Public Sub Swap_NumberFormat(ByVal rngSingleColumn As Range)
Dim rngToFormat As Range
Application.ScreenUpdating = False 'might speed it up
Set rngSingleColumn = rngSingleColumn
For Each cell In rngSingleColumn
If .Value = 0 Then
.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* "" - ""??_);_(@_)"
.HorizontalAlignment = -4108
Else
.NumberFormat = "[>9999999]""Rs ""#\,##\,##\,##0.00;[>99999]""Rs ""#\,##\,##0.00;""Rs ""#,##0.00"
.HorizontalAlignment = -4152
End If
Next
End Sub
Bookmarks