Conditional format numbers

  • Thread starter Thread starter PiPPo
  • Start date Start date
P

PiPPo

Hi,
This is my problem. I would like to format a number in B1 on the basis
of a certain condition in A1.
I read in another post that I need a macro to conditional format
numbers. Is that correct? Where can I find such macro? If this is not
the case, can anyone help me with my problem?

Thank you,

Pippo
 
Well,

What I need is to format the value in a cell on the basis of a
condition in another cell. The number I want to format has to assume
one of the three following formats: X%, X or Xd, where X is a not
bounded number of figures . In other words, the value may be a
percentage, an integer number or a special format Xd.

Dos anyone have an idea?

Thank you very much
 
Perhaps if you gave us some specific examples.

It would also help if you told us what the condition is!!!!!!!!!!!

Biff
 
Ok, I apologize for not being clear.

In A1 I want to put one of the following three strings of text:
"Inventory", "Inventory - % of COGS", "Inventory - DIO". Cell B1 has to
be formatted as an integer number if "Inventory" is chosen, a
percentage number if "Inventory - % of COGS" is chosen or as a special
format Xd (where d stands for days) when the third condition is
selected.

Thank you again.
 
You cannot use Conditional formatting to change number formats so you
would need to use a worksheet change event something like this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
Application.EnableEvents = False
If Target.count = 1 And Target.Address = "$A$1" Then
Select Case Target.Value
Case "Inventory"
Range("B1").NumberFormat = "#,##0"
Case "Inventory - % of COGS"
Range("B1").NumberFormat = "0.00%"
Case "Inventory - DIO"
Range("B1").NumberFormat = "Xd"
End Select
End If
ErrorHandler:
Application.EnableEvents = True
End Sub

This is worksheet event code. Right click the sheet tab, select View
Code and Paste the code in there.

Hope this helps
Rowan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top