View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett
 
Posts: n/a
Default Excel should allow you to create borders around columns easier

OK. Try this

Sub ColumnBorders()
Dim rng As Range
Set rng = Selection 'Range("a1", "d10")
'MsgBox rng.Address
fr = rng.Cells(1).Row
'MsgBox "first row is " & fr
fc = rng.Cells(1).Column 'Range("a1").Address
'MsgBox "first column is " & fc
lr = Range(rng.Address). _
Cells(Range(rng.Address).Cells.Count).Row
'MsgBox "Last row is " & lr
lc = Range(rng.Address). _
Cells(Range(rng.Address).Cells.Count).Column
'MsgBox "last column is " & lc
numcols = lc - fc + 1
'MsgBox numcols
For i = fc To numcols - 1 + fc
Range(Cells(fr, i), Cells(lr, i)). _
BorderAround Weight:=xlMedium
'MsgBox i
Next i
Cells(fr, fc).Select
End Sub

--
Don Guillett
SalesAid Software

"robinsongary" wrote in message
...
I ran your code but it puts a border around every cell. What I was looking
for was selecting a number of columns containing a number of cells, say a
10
by 10 block. I would like just the columns to have a border. Not every
cell
within the column. Thanks for the suggestion though.

"Don Guillett" wrote:

How about

Sub doborders()
Selection.Borders.Weight = xlMedium 'Thick
End Sub

--
Don Guillett
SalesAid Software

"robinsongary" wrote in message
...
Excel provides a number of options for creating borders around selected
cells, but does not do a good job at allowing you to automatically
format
colums with borders. For example, if are working with Columns A-B-C
and
rows
2-10 and want to put a border around each column (A2-A10, B2-B10, and
C2-C10), you have to select each column and select the "box" border.
What
would be great is if there was a button that you could push that would
do
this for you, like when you select a group of cells and want every cell
in
that group to have a border.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the
"I
Agree" button in the message pane. If you do not see the button, follow
this
link to open the suggestion in the Microsoft Web-based Newsreader and
then
click "I Agree" in the message pane.

http://www.microsoft.com/office/comm...lic.excel.misc