9 Replies Latest reply: Jun 13, 2016 6:17 PM by Marco Wedel RSS

    Type Mismatch error

      I am using this code to change 1's to green and 0's to red. This works fine in Excel, but when I transfer the VBA code to qlikview, it no longer works, giving me the error "Type Mismatch:Range" at the third line. Any help would be appreciated.




      Sub changeTextColor()  

          Dim v, clr, rng, x


          Set rng = Range("Verifier Concat")                //Problem at this line with "Type Mismatch"


          Do While rng.Value <> ""

              v = rng.Value  


              For x = 1 To Len(v)

                  Select Case Mid(v, x, 1)

                     Case "1": clr = RGB(0, 128, 0)

                     Case "0": clr = RGB(255, 0, 0)

                  End Select


                  rng.Characters(x, 1).Font.Color = clr

                  rng.Characters.Font.Bold = True 




              Set rng = rng.Offset(1, 0)


      End Sub