VBA Editor Error Message

VBA Editor Error Message

I keep getting the following error message: Encountered error at line 3 :For input string: "transparent" when running this macro:

Public Sub ApplyBackgroundColor()
    Dim x As Variant
    x = ActiveCell.Interior.Color
    With Selection.borders
        .LineStyle = xlContinuous
        .Weight = xlThin
        .Color = x
    End With
    Selection.Interior.Color = x
End Sub 

I alsoget this message for line 22 of the following macro:

Sub ClearAllBorder()

Dim colorVal as Variant

colorVal = Selection.Cells(1,1).Interior.Color

    With Selection.borders(xlEdgeLeft)

        .LineStyle = xlContinuous

        .Weight = xlThin

        .Color = colorVal 

    End With

    With Selection.borders(xlEdgeTop)

        .LineStyle = xlContinuous

        .Weight = xlThin

        .Color =  colorVal 

    End With

    With Selection.borders(xlEdgeRight)

        .LineStyle = xlContinuous

        .Weight = xlThin

        .Color =  colorVal 

    End With

    With Selection.borders(xlEdgeBottom)

        .LineStyle = xlContinuous

        .Weight = xlThin

        .Color =  colorVal 

    End With

    With Selection.borders(xlInsideHorizontal)

        .LineStyle = xlContinuous

        .Weight = xlThin

        .Color = colorVal 

    End With

    With Selection.borders(xlInsideVertical)

        .LineStyle = xlContinuous

        .Weight = xlThin

        .Color =  colorVal 

    End With

End Sub 
 

Can you help? What other details do you need??

Kind regards
Hans