Announcement

Collapse
No announcement yet.

USD 20 VBA code to color cells if it meets percentage range conditions

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • USD 20 VBA code to color cells if it meets percentage range conditions

    Hello! Need help in creating a macro that will color code cells in Col N and Col P if it meets the below criteria:
    • 0-50% - red
      50-75%- yellow
      75%-up- green





    Transaction ID: 535857935X6354151

    Thank you!
    Attached Files

  • #2
    Re: VBA code to color cells if it meets percentage range conditions $20

    I'll have a look and let you know if I can help.
    Cheers,

    S M C

    Click To Read: How To Use Tags In Your Threads/Posts
    Please take time to read Forum Rules before posting
    Message To Cross Posters

    Comment


    • #3
      Re: VBA code to color cells if it meets percentage range conditions $20

      Don't worry about the payment. Use this code. By the way, your existing code which does your other work is highly inefficient. Can be done in a much more easier (read efficient) manner

      Code:
      Sub ColorFormat()
      
      
          Set objCF = Application.Union(Range("N2:N" & Range("N" & Rows.Count).End(xlUp).Row), Range("P2:P" & Range("P" & Rows.Count).End(xlUp).Row))
          With objCF
              .FormatConditions.Delete
              With .FormatConditions.Add(xlCellValue, xlGreater, "=0.75")
                  .Interior.Color = 5287936
              End With
              With .FormatConditions.Add(xlCellValue, xlLess, "=0.5")
                  .Interior.Color = 255
              End With
              With .FormatConditions.Add(xlCellValue, xlBetween, "=0.5", "=0.75")
                  .Interior.Color = 49407
              End With
          End With
          
      End Sub
      Cheers,

      S M C

      Click To Read: How To Use Tags In Your Threads/Posts
      Please take time to read Forum Rules before posting
      Message To Cross Posters

      Comment


      • #4
        Re: VBA code to color cells if it meets percentage range conditions $20

        Thank you so much SMC!

        Comment


        • #5
          Re: VBA code to color cells if it meets percentage range conditions $20

          Cheers mate
          Cheers,

          S M C

          Click To Read: How To Use Tags In Your Threads/Posts
          Please take time to read Forum Rules before posting
          Message To Cross Posters

          Comment

          Working...
          X