K.Vanlalliana 0 Light Poster

Hi, all programmers of this Forum, I am using MS Axcel 2002 and I am trying to format Excel Sheet from VB so as to make a border within the selected cell. My CB code is as under and when I run this, it select the specified rangge, but no line / border is made. It simply finished.


CODE USED:

X.ActiveSheet.Range("A16:U48").Select
selection.Borders(xlDiagonalDown).LineStyle = xlNone
selection.Borders(xlDiagonalUp).LineStyle = xlNone

With selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With


For changing color of text to Red, I used this code as below, and it work correctly:

'Selected range colour nan
X.Range("B2").Select
With selection.Font
.Name = "Arial"
.fontStyle = "Bold"
.Size = 10
.Strikethrough = False
.superScript = False
.subScript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With

Can any one give the the solution for above problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.