View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
BruceD[_2_] BruceD[_2_] is offline
external usenet poster
 
Posts: 3
Default xlNone incorrectly valued?

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