View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default A MACRO TO BUILD BORDERS

try this one line (broken with continuation character)

Sub bordernumbers()
Columns(1).SpecialCells(xlConstants, xlNumbers) _
..Borders.LineStyle = xlContinuous
End Sub
--
Don Guillett
SalesAid Software

"lar48ry" wrote in message
oups.com...
Hi - I am a new member of this news group and also new to VBA for
Excel.
I have some programming background that is rather dated (fortran 77,
Basic, and a specialty language called DAL (which, as far as I know is
no longer in existence)). I have procured a few books and surfed the
Excel help sites and have made some headway however, I find that I need
some help with a macro that I am developing.

The macro is intended to create borders around a selected range of
cells. I started by recording a macro to accomplish this. With a
little work I got this to work when I selected a cell in Column A. Now
I want to expand it to create the same borders by selecting the cells
in Column A that has a numerical value. It can do this either
individually or by activating all the cells in Column A that meets the
requirement and doing them at one time. The other criteria for the
macro is to ignore those rows that have already received their borders
(this part I have not even tackled yet, primarily due to the fact that
I can't get the first part to work yet). I have included a copy of
the macro for your perusal and hopefully comments.

In the macro below I receive a 'Run time error' 424 stating that an
Object is required for the line Lastrow =. I don't understand what
Object it is looking for.

Here's hoping that help is on the way!!! And Thank You in advance.


Sub MULTIBORDERS()
' MULTIBORDERS Macro
' Creates multiple borders based on a number being
' entered into column A
'
'

Dim Lastrow As Long
Dim Row_Index As Long
Dim RW As Integer

'Max number of rows
RW = 395
With ActiveSheet
'Search for the last row with data in Column A
Lastrow = Activate.Cells(Rows.Count, "1").End(xlUp).Row
For Row_Index = RW + 5 To Lastrow Step RW
Next
End With
'ActiveCell.Range("A1:I1").Select

'Create a set of borders for each line of the form that has
'information
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 = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.BORDERS(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.BORDERS(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.BORDERS(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Exit Sub
End Sub