View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default cell formatting based on combobox

I think you will need to cycle through each cell

If ComboBox10.Value = "% of Revenue" Then
For Each cell In Sheets("IncStmtAssump").Range("C11:H11")
.Value = format(.Value, "0.00%")
Next cell
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"bruce forster" wrote in message
...
I have written the following code and the worksheet cell formatting does

not work.
THIS IS THE CODE THAT DOES NOT WORK
If ComboBox10.Value = "% of Revenue" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "0.00%")
If ComboBox10.Value = "Input" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "$#,##0")
If ComboBox10.Value = "% Change from Previous Year" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "0.00%")
If ComboBox10.Value = "$ Change from Previous Year" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "$#,##0")


Any suggestions??

THIS IS ALL THE CODE
Private Sub ComboBox10_AfterUpdate()
TextBox66.Value = Sheets("IncStmtAssump").Range("c11")
If ComboBox10.Value = "% of Revenue" Then TextBox66.Text =

format(TextBox66.Text, "0.00%")
If ComboBox10.Value = "Input" Then TextBox66.Text =

format(TextBox66.Text, "$#,##0")
If ComboBox10.Value = "% Change from Previous Year" Then

TextBox66.Text = format(TextBox66.Text, "0.00%")
If ComboBox10.Value = "$ Change from Previous Year" Then

TextBox66.Text = format(TextBox66.Text, "$#,##0")

TextBox67.Value = Sheets("IncStmtAssump").Range("D11")
If ComboBox10.Value = "% of Revenue" Then TextBox67.Text =

format(TextBox67.Text, "0.00%")
If ComboBox10.Value = "Input" Then TextBox67.Text =

format(TextBox67.Text, "$#,##0")
If ComboBox10.Value = "% Change from Previous Year" Then

TextBox67.Text = format(TextBox67.Text, "0.00%")
If ComboBox10.Value = "$ Change from Previous Year" Then

TextBox67.Text = format(TextBox67.Text, "$#,##0")

TextBox68.Value = Sheets("IncStmtAssump").Range("e11")
If ComboBox10.Value = "% of Revenue" Then TextBox68.Text =

format(TextBox68.Text, "0.00%")
If ComboBox10.Value = "Input" Then TextBox68.Text =

format(TextBox68.Text, "$#,##0")
If ComboBox10.Value = "% Change from Previous Year" Then

TextBox68.Text = format(TextBox68.Text, "0.00%")
If ComboBox10.Value = "$ Change from Previous Year" Then

TextBox68.Text = format(TextBox68.Text, "$#,##0")

TextBox69.Value = ""
TextBox70.Value = ""
TextBox71.Value = ""

If ComboBox10.Value = "% of Revenue" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "0.00%")
If ComboBox10.Value = "Input" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "$#,##0")
If ComboBox10.Value = "% Change from Previous Year" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "0.00%")
If ComboBox10.Value = "$ Change from Previous Year" Then

Sheets("IncStmtAssump").Range("C11:H11").Text =
format(Sheets("IncStmtAssump").Range("C11:H11").Te xt, "$#,##0")
End Sub