Text function - Custom format

Folks

Is it possible to do a custom number format into the text function which
will allow me to colour the text similar to conditional formatting. The
problem i have is in one of the reports I have the staff have used one cell
to try and put 2 entries in with a slash in between. Say this is a target
value / agreed value and then at the end of the month I will get an actual
value in another cell which I will want to compare against each and give a
percentage increase or decrease. I have managed to write a formula to
seperate the values and give a percentage back using the text function but
now I want to highlight the increase ( good as green ) and decrease ( bad as
red ) within the formula if I can. Is this possible eg..


this is in cell E51

21,571 / 21,334

this is the actual in F51
20,462


The Formula I have is
=TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
-1)))%,"00")&"%"&" /
"&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
,1)-1)))%,"00")&"%"

What I would like is instead of "00" as the format to now apply the rules I
mentioned earlier as a custom format so that if there is an increase or
decrease the format will be acknowledged sort of like [Red}-00

Is this possible or can anyone suggest a better way of doing this without
increasing number of cells ???

Thanks in advance

Gav !!


0
7/28/2003 2:16:55 AM
excel.misc 78881 articles. 5 followers. Follow

7 Replies
736 Views

Similar Articles

[PageSpeed] 48

Just out of curiosity, is it really that important to keep those 2 values in
one cell? Your situation would be soooo much easier if you did that. As it
is, you have to go through all of this trouble to separate them, and then,
apparently, you want to perform some formatting.
Richard Choate

"Gav !!" <gavin.davidson@qr.com.au> wrote in message
news:rI%Ua.137$U74.6997@news.optus.net.au...
Folks

Is it possible to do a custom number format into the text function which
will allow me to colour the text similar to conditional formatting. The
problem i have is in one of the reports I have the staff have used one cell
to try and put 2 entries in with a slash in between. Say this is a target
value / agreed value and then at the end of the month I will get an actual
value in another cell which I will want to compare against each and give a
percentage increase or decrease. I have managed to write a formula to
seperate the values and give a percentage back using the text function but
now I want to highlight the increase ( good as green ) and decrease ( bad as
red ) within the formula if I can. Is this possible eg..


this is in cell E51

21,571 / 21,334

this is the actual in F51
20,462


The Formula I have is
=TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
-1)))%,"00")&"%"&" /
"&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
,1)-1)))%,"00")&"%"

What I would like is instead of "00" as the format to now apply the rules I
mentioned earlier as a custom format so that if there is an increase or
decrease the format will be acknowledged sort of like [Red}-00

Is this possible or can anyone suggest a better way of doing this without
increasing number of cells ???

Thanks in advance

Gav !!



0
rchoatecpa (136)
7/28/2003 4:43:41 AM
Managers make things difficult - Then I have to do difficult things to make
their life easy

Actually it can't be changed because the report has already been approved by
senior executives and they like it, so now to stop incorrect figures being
calculated this is what I have to work with.

"Richard Choate" <rchoatecpa@NoSpam.com> wrote in message
news:e1RsSLMVDHA.3148@tk2msftngp13.phx.gbl...
> Just out of curiosity, is it really that important to keep those 2 values
in
> one cell? Your situation would be soooo much easier if you did that. As it
> is, you have to go through all of this trouble to separate them, and then,
> apparently, you want to perform some formatting.
> Richard Choate
>
> "Gav !!" <gavin.davidson@qr.com.au> wrote in message
> news:rI%Ua.137$U74.6997@news.optus.net.au...
> Folks
>
> Is it possible to do a custom number format into the text function which
> will allow me to colour the text similar to conditional formatting. The
> problem i have is in one of the reports I have the staff have used one
cell
> to try and put 2 entries in with a slash in between. Say this is a target
> value / agreed value and then at the end of the month I will get an actual
> value in another cell which I will want to compare against each and give a
> percentage increase or decrease. I have managed to write a formula to
> seperate the values and give a percentage back using the text function but
> now I want to highlight the increase ( good as green ) and decrease ( bad
as
> red ) within the formula if I can. Is this possible eg..
>
>
> this is in cell E51
>
> 21,571 / 21,334
>
> this is the actual in F51
> 20,462
>
>
> The Formula I have is
>
=TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
> -1)))%,"00")&"%"&" /
>
"&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
> ,1)-1)))%,"00")&"%"
>
> What I would like is instead of "00" as the format to now apply the rules
I
> mentioned earlier as a custom format so that if there is an increase or
> decrease the format will be acknowledged sort of like [Red}-00
>
> Is this possible or can anyone suggest a better way of doing this without
> increasing number of cells ???
>
> Thanks in advance
>
> Gav !!
>
>
>


0
7/28/2003 6:54:36 AM
Let me suggest the Ozgrid/Dave Hawley site because he has a lot of cell
formatting stuff which might help you. Here is the link:
http://www.ozgrid.com/
Richard Choate
"Gav !!" <gavin.davidson@qr.com.au> wrote in message
news:MM3Va.149$U74.8323@news.optus.net.au...
Managers make things difficult - Then I have to do difficult things to make
their life easy

Actually it can't be changed because the report has already been approved by
senior executives and they like it, so now to stop incorrect figures being
calculated this is what I have to work with.

"Richard Choate" <rchoatecpa@NoSpam.com> wrote in message
news:e1RsSLMVDHA.3148@tk2msftngp13.phx.gbl...
> Just out of curiosity, is it really that important to keep those 2 values
in
> one cell? Your situation would be soooo much easier if you did that. As it
> is, you have to go through all of this trouble to separate them, and then,
> apparently, you want to perform some formatting.
> Richard Choate
>
> "Gav !!" <gavin.davidson@qr.com.au> wrote in message
> news:rI%Ua.137$U74.6997@news.optus.net.au...
> Folks
>
> Is it possible to do a custom number format into the text function which
> will allow me to colour the text similar to conditional formatting. The
> problem i have is in one of the reports I have the staff have used one
cell
> to try and put 2 entries in with a slash in between. Say this is a target
> value / agreed value and then at the end of the month I will get an actual
> value in another cell which I will want to compare against each and give a
> percentage increase or decrease. I have managed to write a formula to
> seperate the values and give a percentage back using the text function but
> now I want to highlight the increase ( good as green ) and decrease ( bad
as
> red ) within the formula if I can. Is this possible eg..
>
>
> this is in cell E51
>
> 21,571 / 21,334
>
> this is the actual in F51
> 20,462
>
>
> The Formula I have is
>
=TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
> -1)))%,"00")&"%"&" /
>
"&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
> ,1)-1)))%,"00")&"%"
>
> What I would like is instead of "00" as the format to now apply the rules
I
> mentioned earlier as a custom format so that if there is an increase or
> decrease the format will be acknowledged sort of like [Red}-00
>
> Is this possible or can anyone suggest a better way of doing this without
> increasing number of cells ???
>
> Thanks in advance
>
> Gav !!
>
>
>



0
rchoatecpa (136)
7/28/2003 6:35:16 PM
And one more bad thing:  If your cell is going to contain a formula, then you
can't use that character by character color formatting.  It's whole cell at a
time.

How about a macro that replaces the formulas.  This won't be dynamic which means
if you change the data, you'll have to rerun the macro.

If yes, then I guessed that you have the 3 cells in a row.  The first two
columns are like E51 and F51.  I put the output in G51 (so that it always looks
at the preceding two cells.

So select a bunch of cells and run this:

Option Explicit
Sub fixemUp()

    Dim tempVal0 As Double
    Dim tempVal1 As Double
    Dim tempVal2 As Double
    Dim LeftHandSide As String
    Dim RightHandSide As String
    
    Dim slashPos As Long
    Dim myCell As Range
    Dim myRng As Range
    
    Set myRng = Selection
    
    For Each myCell In myRng.Cells
        If myCell.Column < 3 Then
            'do nothing
        Else
            If IsNumeric(myCell.Offset(0, -1).Value) Then
                tempVal0 = myCell.Offset(0, -1).Value
                slashPos = InStr(1, myCell.Offset(0, -2).Value, " / ")
                If slashPos = 0 Then
                    'do nothing
                Else
                    tempVal1 = CLng(Left(myCell.Offset(0, -2).Value, _
                                       slashPos - 1))
                    tempVal2 = CLng(Right(myCell.Offset(0, -2).Value, _
                                       slashPos - 1))
                    LeftHandSide = Format(tempVal1 / tempVal0 - 1, "00%")
                    RightHandSide = Format(tempVal2 / tempVal0 - 1, "00%")
                    myCell.Value = LeftHandSide & " / " & RightHandSide
                    myCell.Font.ColorIndex = xlAutomatic
                    
                    If Left(LeftHandSide, 1) = "-" Then
                        myCell.Characters(1, Len(LeftHandSide) - 1) _
                                .Font.ColorIndex = 3
                    End If
                    If Left(RightHandSide, 1) = "-" Then
                        myCell.Characters(Len(myCell.Value) _
                              - Len(RightHandSide) + 1, _
                                      Len(RightHandSide) - 1) _
                                           .Font.ColorIndex = 3
                    End If
                End If
            End If
        End If
    Next myCell

End Sub


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



"Gav !!" wrote:
> 
> Managers make things difficult - Then I have to do difficult things to make
> their life easy
> 
> Actually it can't be changed because the report has already been approved by
> senior executives and they like it, so now to stop incorrect figures being
> calculated this is what I have to work with.
> 
> "Richard Choate" <rchoatecpa@NoSpam.com> wrote in message
> news:e1RsSLMVDHA.3148@tk2msftngp13.phx.gbl...
> > Just out of curiosity, is it really that important to keep those 2 values
> in
> > one cell? Your situation would be soooo much easier if you did that. As it
> > is, you have to go through all of this trouble to separate them, and then,
> > apparently, you want to perform some formatting.
> > Richard Choate
> >
> > "Gav !!" <gavin.davidson@qr.com.au> wrote in message
> > news:rI%Ua.137$U74.6997@news.optus.net.au...
> > Folks
> >
> > Is it possible to do a custom number format into the text function which
> > will allow me to colour the text similar to conditional formatting. The
> > problem i have is in one of the reports I have the staff have used one
> cell
> > to try and put 2 entries in with a slash in between. Say this is a target
> > value / agreed value and then at the end of the month I will get an actual
> > value in another cell which I will want to compare against each and give a
> > percentage increase or decrease. I have managed to write a formula to
> > seperate the values and give a percentage back using the text function but
> > now I want to highlight the increase ( good as green ) and decrease ( bad
> as
> > red ) within the formula if I can. Is this possible eg..
> >
> >
> > this is in cell E51
> >
> > 21,571 / 21,334
> >
> > this is the actual in F51
> > 20,462
> >
> >
> > The Formula I have is
> >
> =TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
> > -1)))%,"00")&"%"&" /
> >
> "&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
> > ,1)-1)))%,"00")&"%"
> >
> > What I would like is instead of "00" as the format to now apply the rules
> I
> > mentioned earlier as a custom format so that if there is an increase or
> > decrease the format will be acknowledged sort of like [Red}-00
> >
> > Is this possible or can anyone suggest a better way of doing this without
> > increasing number of cells ???
> >
> > Thanks in advance
> >
> > Gav !!
> >
> >
> >

-- 

Dave Peterson
ec35720@msn.com
0
ec35720 (10082)
7/28/2003 11:17:39 PM
Dave I have tried to run the code but can't seem to get it to work, if
I use 3 columns say A,B & C and I put the following values in each

A1                B1              C1
1000/1400        1200            blank

then I highlight the 3 cells and run the macro - nothing happens

When I did a watch in the backend it says that

Set myRng = Selection
    
    For Each myCell In myRng.Cells
        If myCell.Column < 3 Then
            'do nothing

this part of the code only = 1 so it does nothing. Shouldn't it be
picking up that I have selected 3 columns.

Thanks in advance Gav !!


Dave Peterson <ec35720@msn.com> wrote in message news:<3F25AF13.48D794FB@msn.com>...
> And one more bad thing:  If your cell is going to contain a formula, then you
> can't use that character by character color formatting.  It's whole cell at a
> time.
> 
> How about a macro that replaces the formulas.  This won't be dynamic which means
> if you change the data, you'll have to rerun the macro.
> 
> If yes, then I guessed that you have the 3 cells in a row.  The first two
> columns are like E51 and F51.  I put the output in G51 (so that it always looks
> at the preceding two cells.
> 
> So select a bunch of cells and run this:
> 
> Option Explicit
> Sub fixemUp()
> 
>     Dim tempVal0 As Double
>     Dim tempVal1 As Double
>     Dim tempVal2 As Double
>     Dim LeftHandSide As String
>     Dim RightHandSide As String
>     
>     Dim slashPos As Long
>     Dim myCell As Range
>     Dim myRng As Range
>     
>     Set myRng = Selection
>     
>     For Each myCell In myRng.Cells
>         If myCell.Column < 3 Then
>             'do nothing
>         Else
>             If IsNumeric(myCell.Offset(0, -1).Value) Then
>                 tempVal0 = myCell.Offset(0, -1).Value
>                 slashPos = InStr(1, myCell.Offset(0, -2).Value, " / ")
>                 If slashPos = 0 Then
>                     'do nothing
>                 Else
>                     tempVal1 = CLng(Left(myCell.Offset(0, -2).Value, _
>                                        slashPos - 1))
>                     tempVal2 = CLng(Right(myCell.Offset(0, -2).Value, _
>                                        slashPos - 1))
>                     LeftHandSide = Format(tempVal1 / tempVal0 - 1, "00%")
>                     RightHandSide = Format(tempVal2 / tempVal0 - 1, "00%")
>                     myCell.Value = LeftHandSide & " / " & RightHandSide
>                     myCell.Font.ColorIndex = xlAutomatic
>                     
>                     If Left(LeftHandSide, 1) = "-" Then
>                         myCell.Characters(1, Len(LeftHandSide) - 1) _
>                                 .Font.ColorIndex = 3
>                     End If
>                     If Left(RightHandSide, 1) = "-" Then
>                         myCell.Characters(Len(myCell.Value) _
>                               - Len(RightHandSide) + 1, _
>                                       Len(RightHandSide) - 1) _
>                                            .Font.ColorIndex = 3
>                     End If
>                 End If
>             End If
>         End If
>     Next myCell
> 
> End Sub
> 
> 
> If you're new to macros, you may want to read David McRitchie's intro at:
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
> 
> 
> 
> "Gav !!" wrote:
> > 
> > Managers make things difficult - Then I have to do difficult things to make
> > their life easy
> > 
> > Actually it can't be changed because the report has already been approved by
> > senior executives and they like it, so now to stop incorrect figures being
> > calculated this is what I have to work with.
> > 
> > "Richard Choate" <rchoatecpa@NoSpam.com> wrote in message
> > news:e1RsSLMVDHA.3148@tk2msftngp13.phx.gbl...
> > > Just out of curiosity, is it really that important to keep those 2 values
>  in
> > > one cell? Your situation would be soooo much easier if you did that. As it
> > > is, you have to go through all of this trouble to separate them, and then,
> > > apparently, you want to perform some formatting.
> > > Richard Choate
> > >
> > > "Gav !!" <gavin.davidson@qr.com.au> wrote in message
> > > news:rI%Ua.137$U74.6997@news.optus.net.au...
> > > Folks
> > >
> > > Is it possible to do a custom number format into the text function which
> > > will allow me to colour the text similar to conditional formatting. The
> > > problem i have is in one of the reports I have the staff have used one
>  cell
> > > to try and put 2 entries in with a slash in between. Say this is a target
> > > value / agreed value and then at the end of the month I will get an actual
> > > value in another cell which I will want to compare against each and give a
> > > percentage increase or decrease. I have managed to write a formula to
> > > seperate the values and give a percentage back using the text function but
> > > now I want to highlight the increase ( good as green ) and decrease ( bad
>  as
> > > red ) within the formula if I can. Is this possible eg..
> > >
> > >
> > > this is in cell E51
> > >
> > > 21,571 / 21,334
> > >
> > > this is the actual in F51
> > > 20,462
> > >
> > >
> > > The Formula I have is
> > >
>  =TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
> > > -1)))%,"00")&"%"&" /
> > >
>  "&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
> > > ,1)-1)))%,"00")&"%"
> > >
> > > What I would like is instead of "00" as the format to now apply the rules
>  I
> > > mentioned earlier as a custom format so that if there is an increase or
> > > decrease the format will be acknowledged sort of like [Red}-00
> > >
> > > Is this possible or can anyone suggest a better way of doing this without
> > > increasing number of cells ???
> > >
> > > Thanks in advance
> > >
> > > Gav !!
> > >
> > >
> > >
0
gavnsan (6)
8/4/2003 7:35:29 AM
Just select the cells that get the color adjustment--C1 in this case.

And in your original post, you had your data formatted like:  "1000 / 1400"

slashPos = InStr(1, myCell.Offset(0, -2).Value, " / ")

I think I'd go back and adjust my data to include a leading and trailing space
near the slashes.

If you decide to get rid of all the spaces (Edit|replace " " with nothing), then
try changing the line above to:

slashPos = InStr(1, myCell.Offset(0, -2).Value, "/")





I looked for space-slash-space in that cell.

"Gav !!" wrote:
> 
> Dave I have tried to run the code but can't seem to get it to work, if
> I use 3 columns say A,B & C and I put the following values in each
> 
> A1                B1              C1
> 1000/1400        1200            blank
> 
> then I highlight the 3 cells and run the macro - nothing happens
> 
> When I did a watch in the backend it says that
> 
> Set myRng = Selection
> 
>     For Each myCell In myRng.Cells
>         If myCell.Column < 3 Then
>             'do nothing
> 
> this part of the code only = 1 so it does nothing. Shouldn't it be
> picking up that I have selected 3 columns.
> 
> Thanks in advance Gav !!
> 
> Dave Peterson <ec35720@msn.com> wrote in message news:<3F25AF13.48D794FB@msn.com>...
> > And one more bad thing:  If your cell is going to contain a formula, then you
> > can't use that character by character color formatting.  It's whole cell at a
> > time.
> >
> > How about a macro that replaces the formulas.  This won't be dynamic which means
> > if you change the data, you'll have to rerun the macro.
> >
> > If yes, then I guessed that you have the 3 cells in a row.  The first two
> > columns are like E51 and F51.  I put the output in G51 (so that it always looks
> > at the preceding two cells.
> >
> > So select a bunch of cells and run this:
> >
> > Option Explicit
> > Sub fixemUp()
> >
> >     Dim tempVal0 As Double
> >     Dim tempVal1 As Double
> >     Dim tempVal2 As Double
> >     Dim LeftHandSide As String
> >     Dim RightHandSide As String
> >
> >     Dim slashPos As Long
> >     Dim myCell As Range
> >     Dim myRng As Range
> >
> >     Set myRng = Selection
> >
> >     For Each myCell In myRng.Cells
> >         If myCell.Column < 3 Then
> >             'do nothing
> >         Else
> >             If IsNumeric(myCell.Offset(0, -1).Value) Then
> >                 tempVal0 = myCell.Offset(0, -1).Value
> >                 slashPos = InStr(1, myCell.Offset(0, -2).Value, " / ")
> >                 If slashPos = 0 Then
> >                     'do nothing
> >                 Else
> >                     tempVal1 = CLng(Left(myCell.Offset(0, -2).Value, _
> >                                        slashPos - 1))
> >                     tempVal2 = CLng(Right(myCell.Offset(0, -2).Value, _
> >                                        slashPos - 1))
> >                     LeftHandSide = Format(tempVal1 / tempVal0 - 1, "00%")
> >                     RightHandSide = Format(tempVal2 / tempVal0 - 1, "00%")
> >                     myCell.Value = LeftHandSide & " / " & RightHandSide
> >                     myCell.Font.ColorIndex = xlAutomatic
> >
> >                     If Left(LeftHandSide, 1) = "-" Then
> >                         myCell.Characters(1, Len(LeftHandSide) - 1) _
> >                                 .Font.ColorIndex = 3
> >                     End If
> >                     If Left(RightHandSide, 1) = "-" Then
> >                         myCell.Characters(Len(myCell.Value) _
> >                               - Len(RightHandSide) + 1, _
> >                                       Len(RightHandSide) - 1) _
> >                                            .Font.ColorIndex = 3
> >                     End If
> >                 End If
> >             End If
> >         End If
> >     Next myCell
> >
> > End Sub
> >
> >
> > If you're new to macros, you may want to read David McRitchie's intro at:
> > http://www.mvps.org/dmcritchie/excel/getstarted.htm
> >
> >
> >
> > "Gav !!" wrote:
> > >
> > > Managers make things difficult - Then I have to do difficult things to make
> > > their life easy
> > >
> > > Actually it can't be changed because the report has already been approved by
> > > senior executives and they like it, so now to stop incorrect figures being
> > > calculated this is what I have to work with.
> > >
> > > "Richard Choate" <rchoatecpa@NoSpam.com> wrote in message
> > > news:e1RsSLMVDHA.3148@tk2msftngp13.phx.gbl...
> > > > Just out of curiosity, is it really that important to keep those 2 values
> >  in
> > > > one cell? Your situation would be soooo much easier if you did that. As it
> > > > is, you have to go through all of this trouble to separate them, and then,
> > > > apparently, you want to perform some formatting.
> > > > Richard Choate
> > > >
> > > > "Gav !!" <gavin.davidson@qr.com.au> wrote in message
> > > > news:rI%Ua.137$U74.6997@news.optus.net.au...
> > > > Folks
> > > >
> > > > Is it possible to do a custom number format into the text function which
> > > > will allow me to colour the text similar to conditional formatting. The
> > > > problem i have is in one of the reports I have the staff have used one
> >  cell
> > > > to try and put 2 entries in with a slash in between. Say this is a target
> > > > value / agreed value and then at the end of the month I will get an actual
> > > > value in another cell which I will want to compare against each and give a
> > > > percentage increase or decrease. I have managed to write a formula to
> > > > seperate the values and give a percentage back using the text function but
> > > > now I want to highlight the increase ( good as green ) and decrease ( bad
> >  as
> > > > red ) within the formula if I can. Is this possible eg..
> > > >
> > > >
> > > > this is in cell E51
> > > >
> > > > 21,571 / 21,334
> > > >
> > > > this is the actual in F51
> > > > 20,462
> > > >
> > > >
> > > > The Formula I have is
> > > >
> >  =TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
> > > > -1)))%,"00")&"%"&" /
> > > >
> >  "&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
> > > > ,1)-1)))%,"00")&"%"
> > > >
> > > > What I would like is instead of "00" as the format to now apply the rules
> >  I
> > > > mentioned earlier as a custom format so that if there is an increase or
> > > > decrease the format will be acknowledged sort of like [Red}-00
> > > >
> > > > Is this possible or can anyone suggest a better way of doing this without
> > > > increasing number of cells ???
> > > >
> > > > Thanks in advance
> > > >
> > > > Gav !!
> > > >
> > > >
> > > >

-- 

Dave Peterson
ec35720@msn.com
0
ec35720 (10082)
8/4/2003 11:11:29 PM
Thanks Dave Works like a Dream - Your a Guru


Dave Peterson <ec35720@msn.com> wrote in message news:<3F2EE821.223AF5BA@msn.com>...
> Just select the cells that get the color adjustment--C1 in this case.
> 
> And in your original post, you had your data formatted like:  "1000 / 1400"
> 
> slashPos = InStr(1, myCell.Offset(0, -2).Value, " / ")
> 
> I think I'd go back and adjust my data to include a leading and trailing space
> near the slashes.
> 
> If you decide to get rid of all the spaces (Edit|replace " " with nothing), then
> try changing the line above to:
> 
> slashPos = InStr(1, myCell.Offset(0, -2).Value, "/")
> 
> 
> 
> 
> 
> I looked for space-slash-space in that cell.
> 
> "Gav !!" wrote:
> > 
> > Dave I have tried to run the code but can't seem to get it to work, if
> > I use 3 columns say A,B & C and I put the following values in each
> > 
> > A1                B1              C1
> > 1000/1400        1200            blank
> > 
> > then I highlight the 3 cells and run the macro - nothing happens
> > 
> > When I did a watch in the backend it says that
> > 
> > Set myRng = Selection
> > 
> >     For Each myCell In myRng.Cells
> >         If myCell.Column < 3 Then
> >             'do nothing
> > 
> > this part of the code only = 1 so it does nothing. Shouldn't it be
> > picking up that I have selected 3 columns.
> > 
> > Thanks in advance Gav !!
> > 
> > Dave Peterson <ec35720@msn.com> wrote in message news:<3F25AF13.48D794FB@msn.com>...
> > > And one more bad thing:  If your cell is going to contain a formula, then you
> > > can't use that character by character color formatting.  It's whole cell at a
> > > time.
> > >
> > > How about a macro that replaces the formulas.  This won't be dynamic which means
> > > if you change the data, you'll have to rerun the macro.
> > >
> > > If yes, then I guessed that you have the 3 cells in a row.  The first two
> > > columns are like E51 and F51.  I put the output in G51 (so that it always looks
> > > at the preceding two cells.
> > >
> > > So select a bunch of cells and run this:
> > >
> > > Option Explicit
> > > Sub fixemUp()
> > >
> > >     Dim tempVal0 As Double
> > >     Dim tempVal1 As Double
> > >     Dim tempVal2 As Double
> > >     Dim LeftHandSide As String
> > >     Dim RightHandSide As String
> > >
> > >     Dim slashPos As Long
> > >     Dim myCell As Range
> > >     Dim myRng As Range
> > >
> > >     Set myRng = Selection
> > >
> > >     For Each myCell In myRng.Cells
> > >         If myCell.Column < 3 Then
> > >             'do nothing
> > >         Else
> > >             If IsNumeric(myCell.Offset(0, -1).Value) Then
> > >                 tempVal0 = myCell.Offset(0, -1).Value
> > >                 slashPos = InStr(1, myCell.Offset(0, -2).Value, " / ")
> > >                 If slashPos = 0 Then
> > >                     'do nothing
> > >                 Else
> > >                     tempVal1 = CLng(Left(myCell.Offset(0, -2).Value, _
> > >                                        slashPos - 1))
> > >                     tempVal2 = CLng(Right(myCell.Offset(0, -2).Value, _
> > >                                        slashPos - 1))
> > >                     LeftHandSide = Format(tempVal1 / tempVal0 - 1, "00%")
> > >                     RightHandSide = Format(tempVal2 / tempVal0 - 1, "00%")
> > >                     myCell.Value = LeftHandSide & " / " & RightHandSide
> > >                     myCell.Font.ColorIndex = xlAutomatic
> > >
> > >                     If Left(LeftHandSide, 1) = "-" Then
> > >                         myCell.Characters(1, Len(LeftHandSide) - 1) _
> > >                                 .Font.ColorIndex = 3
> > >                     End If
> > >                     If Left(RightHandSide, 1) = "-" Then
> > >                         myCell.Characters(Len(myCell.Value) _
> > >                               - Len(RightHandSide) + 1, _
> > >                                       Len(RightHandSide) - 1) _
> > >                                            .Font.ColorIndex = 3
> > >                     End If
> > >                 End If
> > >             End If
> > >         End If
> > >     Next myCell
> > >
> > > End Sub
> > >
> > >
> > > If you're new to macros, you may want to read David McRitchie's intro at:
> > > http://www.mvps.org/dmcritchie/excel/getstarted.htm
> > >
> > >
> > >
> > > "Gav !!" wrote:
> > > >
> > > > Managers make things difficult - Then I have to do difficult things to make
> > > > their life easy
> > > >
> > > > Actually it can't be changed because the report has already been approved by
> > > > senior executives and they like it, so now to stop incorrect figures being
> > > > calculated this is what I have to work with.
> > > >
> > > > "Richard Choate" <rchoatecpa@NoSpam.com> wrote in message
> > > > news:e1RsSLMVDHA.3148@tk2msftngp13.phx.gbl...
> > > > > Just out of curiosity, is it really that important to keep those 2 values
>  in
> > > > > one cell? Your situation would be soooo much easier if you did that. As it
> > > > > is, you have to go through all of this trouble to separate them, and then,
> > > > > apparently, you want to perform some formatting.
> > > > > Richard Choate
> > > > >
> > > > > "Gav !!" <gavin.davidson@qr.com.au> wrote in message
> > > > > news:rI%Ua.137$U74.6997@news.optus.net.au...
> > > > > Folks
> > > > >
> > > > > Is it possible to do a custom number format into the text function which
> > > > > will allow me to colour the text similar to conditional formatting. The
> > > > > problem i have is in one of the reports I have the staff have used one
>  cell
> > > > > to try and put 2 entries in with a slash in between. Say this is a target
> > > > > value / agreed value and then at the end of the month I will get an actual
> > > > > value in another cell which I will want to compare against each and give a
> > > > > percentage increase or decrease. I have managed to write a formula to
> > > > > seperate the values and give a percentage back using the text function but
> > > > > now I want to highlight the increase ( good as green ) and decrease ( bad
>  as
> > > > > red ) within the formula if I can. Is this possible eg..
> > > > >
> > > > >
> > > > > this is in cell E51
> > > > >
> > > > > 21,571 / 21,334
> > > > >
> > > > > this is the actual in F51
> > > > > 20,462
> > > > >
> > > > >
> > > > > The Formula I have is
> > > > >
>  =TEXT((TRIM(LEFT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(LEFT(E51,FIND("/",E51,1)
> > > > > -1)))%,"00")&"%"&" /
> > > > >
>  "&TEXT((TRIM(RIGHT(E51,FIND("/",E51,1)-1))-F51)/(TRIM(RIGHT(E51,FIND("/",E51
> > > > > ,1)-1)))%,"00")&"%"
> > > > >
> > > > > What I would like is instead of "00" as the format to now apply the rules
>  I
> > > > > mentioned earlier as a custom format so that if there is an increase or
> > > > > decrease the format will be acknowledged sort of like [Red}-00
> > > > >
> > > > > Is this possible or can anyone suggest a better way of doing this without
> > > > > increasing number of cells ???
> > > > >
> > > > > Thanks in advance
> > > > >
> > > > > Gav !!
> > > > >
> > > > >
> > > > >
0
gavnsan (6)
8/7/2003 10:17:10 AM
Reply:

Similar Artilces:

TEXT = text
I have some data in an Excel table which uses case sensitive codes. Does anyone know of a way to perform case sensitive VLookups. Example. A1 contains "TEXT", A2 contains "One". B1 contains "text", B2 contains "Two" If I enter "text" in cell A4 and the following VLookup in B4: =VLOOKUP(A4;A1:B2;2;FALSE) I get the answer "One", but I would like to see "Two". I have found a work around by converting a number of characters to their ASCII codes, but this is very messy. I know that the FIND function is case sensitive whe...

Selecting text in a document
Hi, I have a macro which finds a certain piece of text in the document and then moves down a line and then selects all the text between that and the end of the document and the selected text is later sent out in an email. This has been working for some time but I have recently had some problems because the text is not being selected as before (extendmode on?) and I am sending out blank emails. The code fragment that I use to select the text is as follows Selection.HomeKey wdStory Selection.Find.Execute "Issued at" Selection.MoveDo...

What is the Limit of Text Boxes & Labels a User Form can have?
What is the Max File Size a User Form can be? I have Windows 7 with Office 2007. Does it have like a 64K limit? The file size as far as kb. My entire Program is 1,203 Kb. When I ran it I got a "compile Error out of memory", so I exported my User Form. Then I looked at the file size of just the User Form in a blank Workbook 34 KB = .frm 219 KB = frx My user Form is a Multi Page with 4 Pages on it. There are alot of text boxes and labels on the 4 sheets. Is there a limit to the number of text boxes & labels you can have in a user Form? I have 12 GB of ...

Resizing cells to fit text returned by VLOOKUP
I have some VLOOKUPs which sometimes return 50 or 60 characters (they're in merged cells). I want the text to wrap, and the cell to enlarge to fit the text - Just like it does whan you type it in, but somehow, because it is being returned from a formula it just displays the bottom line of the wrapped text, and doesn't resize the row. Anyone know how I cam make it fit? I'm happy to use a VBA solution if there's no built in way to make it happen automatically. Thanks M Would you mind to limit your request to ONE newsgroup? Joerg "Michelle" <mh_londonNOJUN...

CScrollView and text height
I call DrawText to draw text on the CScrollView.When text has multi-line,how do I get the screen height to draw them? Thanks. ___________________________________ http://www.msale.net/bbs a Chinese-language message board for developers,including palm,ppc,symbian,and etc. http://www.zirong.net/blog/ Miken's private life If you are trying to calculate the height of a multiline string user DrawText with the DT_CALCRECT flag. It will use the width of the Rect that you pass it, and sets the bottom of the rect to what the bottom would be if you draw it. AliR. "Miken" <mikenwon...

Text Boxes on Charts not showing up
Has anyone experienced this? I've got a chart in a spreadsheet and I add text boxes to the graph section. They appear on the page yet when I click off the page, the text box disappears. If I go to print preview, the text boxes are there so why can't I see them on the screen? I've tried the bring forward command but that didn't work. This is also sporadic as some of my text boxes stay in place why others seem to disappear. Sue - If the chart is selected when you draw the text box, the text box becomes part of the chart. If not, the text box just floats along in the dr...

formatting a spreadsheet help
I have a few different dilemas going on here. First: Can a conditional format be set up in Vista or Windows 7 both 64 bit, and saved in 97-2003 excel saving the conditional formats? Second: I have a spreadsheet column A is my received date, Column B is Stock #, Column C is Serial #, Column G is my finished date. What I need to be able to do: When I enter information into Column C (Serial #), I need some type of notification if that same number has been entered within a six month time period from my Column G (Finished date). 1. Yes. However, there are some formats which only Ex...

Function is not availalbe in expressions in query expression error message (0/1)
I recently received this error message when opening the source DB in Access 2007. I have attached two jpg pics. Does this error message give enough details for someone to point me in the right direction for a fix? The last time I developed and worked in this DB everything worked fine. I get this error when clicking on a control that runs a query macro against a backend DB consisting of about 15 tables. I should mention the error comes into play when trying to run the frontend on a client W/S. I don't see the error while on my W/S which is my developer W/S and has Acce...

avoid losing text when text submission timed out?
Often I have to log in to some web site to enter a few paragraphs of text (e.g. web email submission, user forum, product reviews, etc). Sometimes it takes me a while to compose the text, and by the time I click submit, I get a response saying the session has timed out, and the text that took me a long time to compose is gone. Is there a way to retrieve this text? Clicking the back button doesn't work. Perhaps it is in a cache somewhere? The portion of the web page containing your text may or may not be in TIF, but here's what I do: Before I hit the 'Submit'...

Ranking Numbers with Text
I am trying to sort a list of serial numbers containing alpha an numeric text into ascending order so LOOKUP will work. ie: 5KJJAHAS63PL84681 input into col. E 5KJJAHAS43PL84685 5KJJAHASx3PL84683 5KJJAHAS83PL84686 5KJJAHAS63PL84689 5KJJAHAS43PL84684 5KJJAHAS23PL84682 5KJJAHAS03PL84688 5KJJAHASx3PL84610 5KJJAHAS83PL84690 5KJJAHAS83PL84691 Only the ninth and 13 thru 17 digits change. Worksheets are protected except for inputs. I need the sort to use the LOOKUP function. I tried =IF(E3>0,(RIGHT(E3,5)*1),999999) to RANK by the last 5 =RANK(D3,D$3:D$102,1)+COUNTIF(D$3:D3,D3)-1, but then LOOKUP ...

Printing HTML formatted messages
I have noticed that when I print HTML formatted messages, the current date is printed in the lower left corner of every page. It also seems do ignore the Header/Footer settings form the memo or table style settings. Can I disable the date from printing out on the page? Thanks. Ben ...

Format cell for negative
Hi I want the value that i type into a cell always to be negative thanks Hi, You need to adjust the format of the cell - this one for instance: -* #,##0_-;-* #,##0_-;_-* "-"_-;_-@_- Notice that the format starts with "-". Go to Format->Cells->Number and paste this format in the custom part. Cheers, Jon "es" wrote: > Hi > I want the value that i type into a cell always to be > negative > > thanks > Is there a specific Cell or range of cells on your worksheet that you want this? Or any and all cells on any Worksheet? "e...

Null in text box
Can anyone see what might be wrong withthis procedure? Private Sub Job_Number_BeforeUpdate(Cancel As Integer) If IsNull(Me.Job_Number) = True Then MsgBox "No Job Number Entered" Cancel = True End If End Sub -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200707/1 "Haggr1 via AccessMonster.com" <u35393@uwe> wrote in news:74fa8171f7137@uwe: > Can anyone see what might be wrong withthis procedure? > > Private Sub Job_Number_BeforeUpdate(Cancel As Integer) > > If IsNull(Me.Job_...

convert text case in same column or row?
How do I convert text case in the same colum or row. At the moment I use UPPER, but have to create a new column/row. You may find this to be handy Sub ChangeCase() 'Don Guillett Application.ScreenUpdating = False Dim r As Range nCase = UCase(InputBox("Enter U for UPPER" & Chr$(13) & " L for lower" & Chr$(13) & " Or " & Chr$(13) & " P for Proper", "Select Case Desired")) Select Case nCase Case "L" For Each r In Selection.Cells If r.HasFormula Then r.Formula = LCase(r.Formul...

I TYPE IN A TEXT BOX AND IT COPIES THE TEXT TO OTHER TEXT BOXES
Does anyone know how to fix this? Shari wrote: > Does anyone know how to fix this? ================================ Are you editing text on the Master page? -- John Inzer MS Picture It! - Digital Image MVP Digital Image Highlights and FAQs http://support.microsoft.com/ph/695 Notice This is not tech support I am a volunteer Solutions that work for me may not work for you Proceed at your own risk Yes, I thinnk so. :-) I'm not on the background. It's an 8 pg brochure I'm creating and it didn't do it before I added page 8. ...

IF function 11-15-09
If I create a function which checks for text in a cell, it gives a #NAME? error. I have a sheet with a cell containing the text 'Single'. In another cell I want to check for that word so I type =if(a1=''Single'', 1,2). Is there something wrong with that IF, it happens with any text I check for. Perhaps you need to use a semicolon rather than a comma - try it this way: =3DIF(A1=3D"Single";1;2) Hope this helps. Pete On Nov 15, 8:31=A0pm, Imani <Im...@discussions.microsoft.com> wrote: > If I create a function which checks for text ...

Re: Using Text Styles
Front page will not have a Next Edition. AFAIK it is dead. > Ed Bennett wrote: > > Ron Hagley wrote: > >> I have a document with Headings on one line followed by a linespace > >> then on a new line a subheading followed by (on the same line ) a > >> description > >> > >> I wish to use TEXT STYLES as this pattern repeats many times, I have > >> no problem seting up the styles for the headings, but when I do the > >> same for the SUBHEADINGS the text style is applied to the WHOLE line > >> including the description...

Text in Cell as Formula #2
Peo + Julie Many thanks for your answer with the last query. I Have a similar question, please advise: This method [INDIRECT()] does work with values form a different spreadsheet. I type the link (as text) from a different spreadsheet in a cell in the current spreadsheet and use this method to call a value in a cell. Would appreciate a detailed answer (if complicated) - I'm a novice user! Many thanks in advance. ...

Logical Test: Text Against Number 01-05-10
Can anyone provide insight into how Excel treats this type of test? For example, why does Excel return TRUE when we have ="a">2 but FALSE when ="a"<2 (or any other number for that matter). Thanks. That's the way it is treated. Any kind of text is larger than the largest number. Any worth? hit the YES below -- Max Singapore --- "rslaughter5" wrote: > Can anyone provide insight into how Excel treats this type of test? For > example, why does Excel return TRUE when we have ="a">2 but FALSE when ="a"<2 ...

Rotate text?
Office(publisher) 2K. Is there anyway to rotate a specific word in a sentence? L. Not if it's part of the sentence rather than being a separate text box. -- JoAnn Paules MVP Microsoft [Publisher] "L." <ofallon12320@yahoo1.com> wrote in message news:%23TBzesS9FHA.2616@TK2MSFTNGP15.phx.gbl... > Office(publisher) 2K. > > Is there anyway to rotate a specific word in a sentence? > > L. > > Thanks for the info. L. "JoAnn Paules [MSFT MVP]" <jl_paules@hotmail.com> wrote in message news:U46dnd7PfZ5CTBHenZ2dnUVZ_sidnZ2d@suscom....

Plain text warning/ VS2005
Whenever I add a CRecordset derived class, I get an error telling me the password for the DB is sent in "plain text" and is not secure etc. I comment that line out, but how much of a security risk is this? What can I do with my Access database to avoid this? VC 6.0 never gave this error... tia b If you are on any kind of network that anyone can look at, you are wide open for attack. Example, a University network; potentially, ever student can be running a packet sniffer and see your password. Anything that passes acros the Internet outside your local intranet is also vuln...

shading behind text
I would like to place white text within a box of gray shading. When I use the 'background' function, it shades the entire document. How do I limit the background to a line of text? thanks Ken Depending on your preference I can think of at least 3 ways, but they all may not be available to you... or instructions may vary. It depends on what version of Word you're using & you haven't even indicated whether it's Windows or Mac. Since you posted to the Mac Word group I'll assume you're using a Mac version & further that it is the most current (2008):...

How to get the text of each selection?
Hi, Dear All We can use Ctrl key and mouse to multi-select range in a document, but if somebody could tell me how to get the text of each selection? Cheers! osen Sorry, it is not really possible. See http://support.microsoft.com/?kbid=288424. The closest you can come is to use Selection.Copy, then open a new blank document and paste. The individual pieces will be separated by paragraph marks, but you can't distinguish between those and any paragraph marks that might have been in the middle of some pieces. -- Regards, Jay Freedman Microsoft Word MVP FA...

Excel format display
Does anybody know how to display the keystrokes in Excel to assist in editing? Donna The wording here is a little ambiguous. Could you re-post with a better descriptions? If you want a list of shortcut keys for editing, see Help>Answer Wizard or Index on "shortcut keys". Gord Dibben Excel MVP On Tue, 1 Jun 2004 06:21:03 -0700, "Donna" <anonymous@discussions.microsoft.com> wrote: >Does anybody know how to display the keystrokes in Excel to assist in editing? ...

Text Search in for the field of memo does not workd
hello, Here is my VBA, but does not work for text search in my textbox search. Private Sub Txtcari_AfterUpdate() Dim strSQL As String strFilter = "([Nota] LIKE """ & "*" & Me.Txtcari & "*" & """)" Me.Filter = strFilter Me.FilterOn = True CurrentDb.Execute strSQL, dbFailOnError End Sub Thanks in advance for your help. -- H. Frank Situmorang You've declared strSQL, and you attempt to use its content with the Execute method, but you haven't assigned anything to it. -- Doug Steele, Microsoft Access M...