2 Replies Latest reply: Mar 15, 2017 4:09 AM by Mindaugas Bacius RSS

    Macros. FormatConditions

    Mindaugas Bacius

      Hei,

       

      I am facing a problem. There is my part of the macro:

      XLDoc.Sheets(1).Range("E2:E15").Select

       

      SET cfColorScale = Selection.FormatConditions.AddColorScale.ColorScaleType(3)

       

      cfColorScale.ColorScaleCriteria(1).FormatColor.Color = RGB(99, 190, 123)
      cfColorScale.ColorScaleCriteria(2).FormatColor.Color = RGB(255, 235, 134)
      cfColorScale.ColorScaleCriteria(3).FormatColor.Color = RGB(248, 105, 107)

       

      There is the error:

      Screenshot_1.jpg

       

      What I am doing wrong and could you help my out?

       

      Thank you!

        • Re: Macros. FormatConditions
          Tresesco B

          Try like:

           

          SET cfColorScale = XLDoc.Sheets(1).Range("E2:E15").FormatConditions.AddColorScale.ColorScaleType(3)

            • Re: Macros. FormatConditions
              Mindaugas Bacius

              I've already tried this option unsuccessfully:

              Screenshot_1.jpg

               

              I've managed to come with correct script in VBA unfortunately in VBS it differs and I cannot come across the correct code:

              Sub CreateColorScaleCF()

              Range("B1:B10").Select

              Set cfColorScale = Selection.FormatConditions.AddColorScale(ColorScaleType:=3)

              cfColorScale.ColorScaleCriteria(1).FormatColor.Color = RGB(99, 190, 123)

              cfColorScale.ColorScaleCriteria(2).FormatColor.Color = RGB(255, 235, 134)

              cfColorScale.ColorScaleCriteria(3).FormatColor.Color = RGB(248, 105, 107)

              End Sub