Consulting

Results 1 to 9 of 9

Thread: Formula to change text colour and add a value to another cell

  1. #1
    Knowledge Base Approver
    Space Cadet
    VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location

    Formula to change text colour and add a value to another cell

    Hi there. this is my first post in the excel help section so bear with me .

    One of our marketing people asked me if its possible to look at the text value of a cell (either yes/no/maybe) and if its yes, change the text colour in the cell to Red and add +1 to anothers cells count value. I'm not entirely sure how to do this and also would like to know if its possible to do it with just formula's and not with VBA, if not what event woudl I have to check for to do this?. This formula would need to be applied to a column.

    thanks in advance
    Andrew;?
    Nothing annoys a non-conformist more than other non-conformists who refuse to conform to the rules of non-conformity.


    Confused is my normal state of mind


  2. #2
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    The first part you can do with conditional formatting. The second part would require some vba

    Option Explicit
    Option Compare Text 
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Column() <> 1 Then Exit Sub
        If Target = "yes" Then
            Target.Offset(0, 2).Value = Target.Offset(0, 2) + 1
        End If
    End Sub

  3. #3
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    Thanks again MD.

    I'm not allowed to download files at work, so if possible could you post an example of how to do the conidtional formatting or point me in the direction of a KB entry?
    Nothing annoys a non-conformist more than other non-conformists who refuse to conform to the rules of non-conformity.


    Confused is my normal state of mind


  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Go to Format/Conditional Formatting and inset the condition as below.
    Note that the case of the letters doesn't matter here.

  5. #5
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi Sandam,

    Click Format/Conditional Formatting, on the left, select Condition1/Cell Value is, in the middle box, select "is equal to" and then type yes in the right-hand box. Now select Format/Patterns (click red) then click OK, and then on the conditional formatting dialog box click OK.

    You can do this with a single cell or a selection. You can also extend it by including a formatted cell in your selection then going back to Conditional Farmatting....

    Regards,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  6. #6
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    thanks to both of you. your help is much appreciated.
    Nothing annoys a non-conformist more than other non-conformists who refuse to conform to the rules of non-conformity.


    Confused is my normal state of mind


  7. #7
    VBAX Newbie
    Joined
    Mar 2005
    Posts
    5
    Location
    Not sure if the part of "counting cells" was rplied to. So you can basically do a formula '=countif("Yes", B1:B200")'. I believe that's the way it goes.

    Good luck.

  8. #8
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by folk754
    Not sure if the part of "counting cells" was rplied to. So you can basically do a formula '=countif("Yes", B1:B200")'. I believe that's the way it goes.

    Good luck.
    Actually, you have it backwards folk. The Range is the first syntax, the Criterion is the second syntax. In your example, it should actually be ..

    =COUNTIF(B1:B200,"Yes")
    Take care.

  9. #9
    Knowledge Base Approver
    Space Cadet VBAX Tutor sandam's Avatar
    Joined
    Jan 2005
    Location
    London
    Posts
    292
    Location
    Thanks again to everyone for their suggestions and explanantions. the conditionl formatting and the countif formula did the job and marketing are happy bunnies.

    Andrew;?
    Nothing annoys a non-conformist more than other non-conformists who refuse to conform to the rules of non-conformity.


    Confused is my normal state of mind


Posting Permissions

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