+ Reply to Thread
Results 1 to 3 of 3

Conditional Number Formatting

  1. #1
    Neda
    Guest

    Conditional Number Formatting

    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

  2. #2
    JE McGimpsey
    Guest

    Re: Conditional Number Formatting

    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("A1")) Is Nothing Then _
    Range("A2:D2").NumberFormat = _
    IIf(Range("A1").Value = 1, "0%", "0.00")
    End Sub


    Adjust the formats as desired.

    In article <2969188E-BC7F-48D2-8A63-A0CF913A11CE@microsoft.com>,
    "Neda" <Neda@discussions.microsoft.com> wrote:

    > 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


  3. #3
    neda5
    Guest

    Re: Conditional Number Formatting

    Works greatly.
    Thanks.

    "JE McGimpsey" wrote:

    > 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("A1")) Is Nothing Then _
    > Range("A2:D2").NumberFormat = _
    > IIf(Range("A1").Value = 1, "0%", "0.00")
    > End Sub
    >
    >
    > Adjust the formats as desired.
    >
    > In article <2969188E-BC7F-48D2-8A63-A0CF913A11CE@microsoft.com>,
    > "Neda" <Neda@discussions.microsoft.com> wrote:
    >
    > > 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

    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1