Jacob,
Here is the full code:
Private Sub ComboBox1_Change()
For Each sh In ActiveWorkbook.Sheets
Select Case Me.ComboBox1.Text
'add as many Case tests as required
Case "$"
Sheets("Contract Data").Select
Range("C7").Select
ActiveCell.FormulaR1C1 = "$"
Range("G4:G34").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
Range("C13:C14").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
Range("C20").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Summary_Gross").Select.NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Summary_Rate").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Summary_Prev").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Adj_Gross").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Adj_Rate").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Adj_Prev").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("K108:K105").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
sh.Range("I67").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
sh.Range("D12
13").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
sh.Range("K16").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
Case "£"
Sheets("Contract Data").Select
Range("C7").Select
ActiveCell.FormulaR1C1 = "£"
Range("G4:G34").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
Range("C13:C14").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
Range("C20").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
sh.Range("I17:I65").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
sh.Range("K17:K65").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
sh.Range("K69:K73").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
sh.Range("I67").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
sh.Range("D12
13").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
sh.Range("K16").NumberFormat = _
"£ #,##0.00;[Red]-(£ #,##0.00)"
Case "€"
Sheets("Contract Data").Select
Range("C7").Select
ActiveCell.FormulaR1C1 = "€"
Range("G4:G34").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
Range("C13:C14").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
Range("C20").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
sh.Range("I17:I65").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
sh.Range("K17:K65").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
sh.Range("K69:K73").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
sh.Range("I67").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
sh.Range("D12
13").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
sh.Range("K16").NumberFormat = _
"€ #,##0.00;[Red]-(€ #,##0.00)"
Case "GEL"
Sheets("Contract Data").Select
Range("C7").Select
ActiveCell.FormulaR1C1 = "GEL"
Range("G4:G34").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
Range("C13:C14").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
Range("C20").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
sh.Range("I17:I65").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
sh.Range("K17:K65").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
sh.Range("K69:K73").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
sh.Range("I67").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
sh.Range("D12
13").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
sh.Range("K16").NumberFormat = _
"[$GEL -437]#,##0.00;[Red]-([$GEL -437]#,##0.00)"
End Select
Next sh
End Sub
It all worked before I started to change ranges (ie. Range("C20:C25) to
named ranges. The reason I am making the changes is when I insert rows, they
will not be correctly formated, but if i make ranges and insert in the
middle, they would be.
Suggestions?
Jacob Skaria said:
In your code what is sh..
Try the below...You can assign the format to a variable...
Dim sh As Worksheet
Dim strFormat As String
Set sh = Sheets("Contract Data")
strFormat = "[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
sh.Range("G4:G34").NumberFormat = strFormat
sh.Range("Summary_Gross").NumberFormat = strFormat
If this post helps click Yes
---------------
Jacob Skaria
Jim said:
I'm having trouble with the following code, it gets stuck at
"sh.Range("Summary_Gross")." What I am trying to do is change the format of
cells, which works fine, but instead of naming cells I would like to name
ranges.
Sheets("Contract Data").Select
Range("C7").Select
ActiveCell.FormulaR1C1 = "$"
Range("G4:G34").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
Range("C13:C14").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
Range("C20").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Summary_Gross").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Summary_Rate").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Summary_Prev").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Adj_Gross").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Adj_Rate").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("Adj_Prev").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0.00)"
sh.Range("K108:K105").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
sh.Range("I67").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
sh.Range("D12
13").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
sh.Range("K16").NumberFormat = _
"[$$-409] #,##0.00;[Red]-([$$-409] #,##0."
Suggestions?
JIM