Edit Layer Properties

I'm comparing layers in a drawing with layers in a spread sheet. And I'm trying to edit the properties of layer if their name exists in the spread sheet.

Here are the codes which I'm trying to use but they are not working as desired.

While Not (xlws.Cells(k, 1).text) = ""

      If xlws.Cells(k, 1).text = swLayer.Name Then

          swLayer.Color = xlws.Cells(k, 3).Value

          swLayer.Style = xlws.Cells(k, 4).Value

          swLayer.Width = xlws.Cells(k, 5).Value

     End If

     k = k + 1

End While

Any pointers would be helpful.

SolidworksApi macros