S
steve.buckley
Howdee all.
Well, this is coming in from the Google Groups-
microsoft.public.excel.programming server-- any way to directly access
the newsgroups anymore? If so-- please explain how, or provide a
link.
Last year, I was talking with Dave Peterson about a macro to loop
based on the borders. Below is the code he'd provided. I now finally
have time to sit down and work through it.
The original post is @
http://groups.google.com/group/micr.../43be577f968cbcf8?show_docid=43be577f968cbcf8
The code is:
Dim Mycell, myRng As Range
Dim topcell, botcell As Range
Set myRng = Selection
For Each Mycell In myRng.Columns(1).Cells
If Mycell.Borders(xlEdgeTop).LineStyle = xlSolid Or
Mycell.Borders(xlEdgeTop).LineStyle = xlDouble Then
Set topcell = Mycell
Else
If Mycell.Borders(xlEdgeBottom).LineStyle = xlSolid Then
If topcell Is Nothing Then
MsgBox "Missing topcell for: " &
Mycell.Address(0, 0)
Else
Set botcell = Mycell
Application.DisplayAlerts = False
ActiveSheet.Range(topcell, botcell).Merge
Application.DisplayAlerts = True
End If
'get ready for next pair
Set topcell = Nothing
Set botcell = Nothing
End If
End If
Next Mycell
In my working through this, it appears to stop before it accomplishes
my goal. I.e., it finds the TopCell, and then exits the macro. I need
it to start working through each cell to find the BotCell, and then
perform the merge operation.
What am I missing here?
Thank you.
Well, this is coming in from the Google Groups-
microsoft.public.excel.programming server-- any way to directly access
the newsgroups anymore? If so-- please explain how, or provide a
link.
Last year, I was talking with Dave Peterson about a macro to loop
based on the borders. Below is the code he'd provided. I now finally
have time to sit down and work through it.
The original post is @
http://groups.google.com/group/micr.../43be577f968cbcf8?show_docid=43be577f968cbcf8
The code is:
Dim Mycell, myRng As Range
Dim topcell, botcell As Range
Set myRng = Selection
For Each Mycell In myRng.Columns(1).Cells
If Mycell.Borders(xlEdgeTop).LineStyle = xlSolid Or
Mycell.Borders(xlEdgeTop).LineStyle = xlDouble Then
Set topcell = Mycell
Else
If Mycell.Borders(xlEdgeBottom).LineStyle = xlSolid Then
If topcell Is Nothing Then
MsgBox "Missing topcell for: " &
Mycell.Address(0, 0)
Else
Set botcell = Mycell
Application.DisplayAlerts = False
ActiveSheet.Range(topcell, botcell).Merge
Application.DisplayAlerts = True
End If
'get ready for next pair
Set topcell = Nothing
Set botcell = Nothing
End If
End If
Next Mycell
In my working through this, it appears to stop before it accomplishes
my goal. I.e., it finds the TopCell, and then exits the macro. I need
it to start working through each cell to find the BotCell, and then
perform the merge operation.
What am I missing here?
Thank you.