Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default xlNone incorrectly valued?

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


"BruceD" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File is in use by <valued customer... read only... etc... Renee R.[_2_] Excel Discussion (Misc queries) 2 January 23rd 09 05:38 PM
Look up valued based on two values Scott Wagner Excel Worksheet Functions 3 May 2nd 07 09:05 PM
MICROSOFT VALUED PROFESSIONAL Abhishek kedia Excel Discussion (Misc queries) 1 May 9th 06 03:21 PM
Conditionally formatting highest valued cell? brett Excel Worksheet Functions 10 December 22nd 05 08:30 AM
How do I subtract with text valued number instead of an actual num Crowraine Excel Worksheet Functions 15 December 17th 04 10:00 PM


All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"