Draw a Line in a Box

B

Barry

Hi

How do i programmatrically draw a Line inside a Box drawn using BorderAround
method
 
B

Bernard Liengme

Do you mean you want to add a border to a cell (or a range) and then draw a
horizontal line?
Not possible with a single cell
With a range, draw a border around each half
best wishes
 
S

Shane Devenshire

Hi,

The only kind of interior borders that you can add are diagonal.

What's the purpose of this? You can fake it with merged cells, shapes or
pictures.
 
B

Barry

Bernard

I am interested in "draw a border around each half", can you explain which
method i would use??

It would be something like this

-------------------
| Buyer/Address |
| ------------------| <== like this
| Jackson |
| Somewhere |
| On Mars |
| Opp Venus |
 
B

Bernard Liengme

Select the cell with "Buyer/Address"
Locate the border tool( in Excel 2003 it is to the right on the Format
toolbar; in Excel 2007 it is in the Font group on the Home tab). Click this
tool's launch arrow. Now select the "Outside Border" item (in Excel 2003 it
is third on the third row, in Excel 2007 it is the seventh item down)
Now your cell has a border around it

Note that the border tool nor shows a single square.
Select the four cells ( Jackson , Somewhere , On Mars, Opp Venus ) and
click the Border tool

This seems to give what you are aiming for
best wishes
 
B

Barry

Bernard,

I was looking for a programmatic solution, not a manual one.

maybe i am on the wrong forum.

Barry
 
B

Bernard Liengme

Have you though of recording a macro as you carry out the step I gave?
This is wahtr I get; as with most recorded macros, iyt has some unrequirted
code that could be editied out
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 14/01/2009 by Bernard V Liengme
'
Range("F6").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("F7:F9").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End Sub

best wishes
 
B

Barry

Hi Bernard

I did find some C#/VB code in MSDN which helped me overcome the problem.
Incidentally, i used code which is along the same lines as the one provided
by you.

Thanks for your efforts.

Barry
 

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

Top