+ Reply to Thread
Results 1 to 4 of 4

Conditional Numerical Formatting

  1. #1
    Qaspec
    Guest

    Conditional Numerical Formatting

    I'd like the number format for the value in cell a3 to be a general number if
    a1 is empty and i'd like the format to be a percentage if a1 contains a
    value.



  2. #2
    JE McGimpsey
    Guest

    Re: Conditional Numerical Formatting

    Since one cell can't change another cell's formatting, this will require
    an Event macro.

    Put this in your worksheet code module (right-click on the worksheet tab
    and choose "View Code")"


    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    With Target(1)
    If .Address(False, False) = "A1" Then
    If IsEmpty(.Value) Then
    Range("A3").NumberFormat = "General"
    Else
    Range("A3").NumberFormat = "0%"
    End If
    End If
    End With
    End Sub





    In article <[email protected]>,
    Qaspec <[email protected]> wrote:

    > I'd like the number format for the value in cell a3 to be a general number if
    > a1 is empty and i'd like the format to be a percentage if a1 contains a
    > value.
    >
    >


  3. #3
    Qaspec
    Guest

    Re: Conditional Numerical Formatting

    What if A1 was on sheet1("Data") and A3 were on sheet2("Daily")? How would I
    change the code?

    "JE McGimpsey" wrote:

    > Since one cell can't change another cell's formatting, this will require
    > an Event macro.
    >
    > Put this in your worksheet code module (right-click on the worksheet tab
    > and choose "View Code")"
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > With Target(1)
    > If .Address(False, False) = "A1" Then
    > If IsEmpty(.Value) Then
    > Range("A3").NumberFormat = "General"
    > Else
    > Range("A3").NumberFormat = "0%"
    > End If
    > End If
    > End With
    > End Sub
    >
    >
    >
    >
    >
    > In article <[email protected]>,
    > Qaspec <[email protected]> wrote:
    >
    > > I'd like the number format for the value in cell a3 to be a general number if
    > > a1 is empty and i'd like the format to be a percentage if a1 contains a
    > > value.
    > >
    > >

    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Conditional Numerical Formatting

    Put the code in the Data sheets
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    set sh = Worksheets("Daily")
    With Target(1)
    If .Address(False, False) = "A1" Then
    If IsEmpty(.Value) Then
    sh.Range("A3").NumberFormat = "General"
    Else
    sh.Range("A3").NumberFormat = "0%"
    End If
    End If
    End With
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Qaspec" <[email protected]> wrote in message
    news:[email protected]...
    > What if A1 was on sheet1("Data") and A3 were on sheet2("Daily")? How would

    I
    > change the code?
    >
    > "JE McGimpsey" wrote:
    >
    > > Since one cell can't change another cell's formatting, this will require
    > > an Event macro.
    > >
    > > Put this in your worksheet code module (right-click on the worksheet tab
    > > and choose "View Code")"
    > >
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > > With Target(1)
    > > If .Address(False, False) = "A1" Then
    > > If IsEmpty(.Value) Then
    > > Range("A3").NumberFormat = "General"
    > > Else
    > > Range("A3").NumberFormat = "0%"
    > > End If
    > > End If
    > > End With
    > > End Sub
    > >
    > >
    > >
    > >
    > >
    > > In article <[email protected]>,
    > > Qaspec <[email protected]> wrote:
    > >
    > > > I'd like the number format for the value in cell a3 to be a general

    number if
    > > > a1 is empty and i'd like the format to be a percentage if a1 contains

    a
    > > > value.
    > > >
    > > >

    > >




+ 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