View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default length of line depending on the value of the cell

Don Guillett submitted this idea :
On Aug 15, 1:55*pm, GS wrote:
Mick,
Why not...

Private Sub Worksheet_Change(ByVal Target As Range)
* Dim rng As Range
* If Not Intersect(Target, Range("A1")) Is Nothing Then
* * Select Case Target.Value
* * * Case Is = 1: Set rng = Range("B1:C1")
* * * Case Is = 2: Set rng = Range("B1:D1")
* * End Select 'Case Target.Value
* * Rows("1:1").Borders(xlEdgeBottom).LineStyle = xlNone
* * With rng.Borders(xlEdgeBottom)
* * * .LineStyle = xlContinuous: .Weight = xlThin
* * * .ColorIndex = 0: .TintAndShade = 0
* * End With
* * Set rng = Nothing
* End If
End Sub

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
Rows(1).Borders(xlEdgeBottom).LineStyle = xlNone
Range(Cells(1, 2), Cells(1, Target + 1)) _
.Borders(xlEdgeBottom).LineStyle = xlContinuous
End Sub


Don,
Your suggestion is NOT addressing the result the OP wants! Also, it's
not as self-documenting for the less skilled programmer.

Range(Cells(1, 2), Cells(1, Target + 1))
is the same as...
Range("B1", "B1")
...because Target must be "A1" for the code to execute.

The result range being changed is conditional on what's entered in A1.
How does your suggestion accomplish this?

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc