G
Guest
Hi,
I'm trying to change format depending the data in a range.
In the cell D10 a "signe $%#", will tell vba to select the right format like
$ or % or #, etc.
The format need to change the range D1117
Exemple if D10 show: $ the range will be change to currency, if the cell D10
show % the range will change to % with 2 decimal.
I did something like this:
Sub FORMATCol()
Dim Col As Range
For Each Col In Range("D1170")
If Range("D10") = "$" Then
Col.NumberFormat = "$#,##0"
End If
Next
' Note: Section if not $ change for #
For Each Col In Range("D1170")
If Range("D10") = "#" Then
Col.NumberFormat = "#,##0"
End If
Next
End Sub
Problem is: I dont know how to tell the sub to select the right format IF
D10 =$ or #
I tried to add another IF (see the line after the ' ) in it, however it's
not working. Can you explain how to to this? Thank you
I'm trying to change format depending the data in a range.
In the cell D10 a "signe $%#", will tell vba to select the right format like
$ or % or #, etc.
The format need to change the range D1117
Exemple if D10 show: $ the range will be change to currency, if the cell D10
show % the range will change to % with 2 decimal.
I did something like this:
Sub FORMATCol()
Dim Col As Range
For Each Col In Range("D1170")
If Range("D10") = "$" Then
Col.NumberFormat = "$#,##0"
End If
Next
' Note: Section if not $ change for #
For Each Col In Range("D1170")
If Range("D10") = "#" Then
Col.NumberFormat = "#,##0"
End If
Next
End Sub
Problem is: I dont know how to tell the sub to select the right format IF
D10 =$ or #
I tried to add another IF (see the line after the ' ) in it, however it's
not working. Can you explain how to to this? Thank you