xlNone incorrectly valued?

  • Thread starter Thread starter BruceD
  • Start date Start date
B

BruceD

This seems very odd.

The following code works fine as long as the choice from
the input box is 1 (thin) or 2 (thick). If it is, xlNone
is valued properly at 2 and 4 respectively.

However,If it's 0 (none) then ib1 gets valued to -4142
and I get run time error 1004 Unable to set Weight
property of Border class.

Any help greatfully appreciated.

Sub Brdrs()
ib1 = InputBox("None (0), Thin (1), or Thick
(2): ", "INNER Border Style", 1)


If ib1 = 0 Then
ib1 = xlNone
ElseIf ib1 = 1 Then
ib1 = xlThin
ElseIf ib1 = 2 Then
ib1 = xlThick
Else
ib1 = xlThin
End If


With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = ib1
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = ib1
.ColorIndex = xlAutomatic
End With
End Sub
 
If I am not mistaken, you apply "xlThin" to the "LineStyle" of the Border as
you have. See small demo below. To make it "None", you apply xlNone to the
LineStyle itself, not the Weight property.

With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
'etc...
End With

Selection.Borders(xlEdgeTop).LineStyle = xlNone


HTH :>)
Dana DeLouis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top