Hi,
I need to number format a group of cells based on the number contained in
another cell. In other words, if the value in A1 is 1 I need to format A2 to
D2 as percent, if the value in A1 is 0 I need to format A2 to D2 as a number.
From, trying to figure out how t odo it I gathered that conditional
formatting will not be able to do it, and I don't know how to write a macro
to do it so any help will be appreciate it.
Thanks in advance.
Neda
one way:
Put this in your worksheet code module (right-click the worksheet tab an
choose View Code):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range(quot;A1quot;)) Is Nothing Then _
Range(quot;A22quot;).NumberFormat = _
IIf(Range(quot;A1quot;).Value = 1, quot;0%quot;, quot;0.00quot;)
End SubAdjust the formats as desired.
In article gt;,
quot;Nedaquot; gt; wrote:
gt; Hi,
gt; I need to number format a group of cells based on the number contained in
gt; another cell. In other words, if the value in A1 is 1 I need to format A2 to
gt; D2 as percent, if the value in A1 is 0 I need to format A2 to D2 as a number.
gt;
gt; From, trying to figure out how t odo it I gathered that conditional
gt; formatting will not be able to do it, and I don't know how to write a macro
gt; to do it so any help will be appreciate it.
gt; Thanks in advance.
gt; Neda
Works greatly.
Thanks.
quot;JE McGimpseyquot; wrote:
gt; one way:
gt;
gt; Put this in your worksheet code module (right-click the worksheet tab an
gt; choose View Code):
gt;
gt; Private Sub Worksheet_Change(ByVal Target As Excel.Range)
gt; If Not Intersect(Target, Range(quot;A1quot;)) Is Nothing Then _
gt; Range(quot;A22quot;).NumberFormat = _
gt; IIf(Range(quot;A1quot;).Value = 1, quot;0%quot;, quot;0.00quot;)
gt; End Sub
gt;
gt;
gt; Adjust the formats as desired.
gt;
gt; In article gt;,
gt; quot;Nedaquot; gt; wrote:
gt;
gt; gt; Hi,
gt; gt; I need to number format a group of cells based on the number contained in
gt; gt; another cell. In other words, if the value in A1 is 1 I need to format A2 to
gt; gt; D2 as percent, if the value in A1 is 0 I need to format A2 to D2 as a number.
gt; gt;
gt; gt; From, trying to figure out how t odo it I gathered that conditional
gt; gt; formatting will not be able to do it, and I don't know how to write a macro
gt; gt; to do it so any help will be appreciate it.
gt; gt; Thanks in advance.
gt; gt; Neda
gt;
- May 16 Wed 2007 20:37
Conditional Number Formatting
close
全站熱搜
留言列表
發表留言