View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Harold Good Harold Good is offline
external usenet poster
 
Posts: 81
Default selecting groups to add border- now with a vertical border too


This is great and works perfectly. But upon looking at the results, I'd
like
not just a border around the outside, but also a thin vertical border
between each column. I guess I could do it manually down the entire column,
but I'm sure it wouldn't be hard to add that to this code below.

Thanks to Tom or anyone that can add that for me to the code below.

Harold

=================
"Tom Ogilvy" wrote in message
...
Assume Loop labels start in A2 and you want 6 columns bordered (change
the 6
in the code below to reflect # of columns).

Sub AA()
Dim StartRow As Range
Dim lastrow As Long
Dim i As Long
Set StartRow = Range("A2")
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, 1).Value < Cells(i + 1, 1).Value Then
StartRow.Resize(i - StartRow.Row + 1, 6).BorderAround _
ColorIndex:=xlAutomatic, Weight:=xlThin
Set StartRow = Cells(i + 1, 1)
End If
Next

End Sub

--
Regards,
Tom Ogilvy




"Harold Good" wrote in message
...
Hi,

I'm so new to VBA that I'm still at the recording macro stage then
trying

to
edit the macro! I have about 6 columns of data and about 1000 rows. I
want
to put borders around those sections that should go together according
to
Loop number. Here's a sample (sorted on the second column), I don't know

how
well the columns will align after I send.

Loop 5J ANG data data data data
Loop 5J ANG data data data data
Loop 5J ANG data data data data

Loop 142 ANG data data data data

Loop 23 JES data data data data
Loop 23 JES data data data data

Above, I entered blank rows to separate the data to indicate the groups

that
should have borders around them. In this example there would be three
separate borders around the three groups.

The criteria is that anytime there is a new Loop number, it begins a new
group that should be inside a common border.

Is this a simple job to write VBA that would border these groups in the

1000
rows according to the Loop criteria above? Any suggestions?

Many thanks,

Harold