Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Howdie all.
I have a macro that I obtained from a poster-- XP-- here last July and have since modified. The goal of the macro is to look through a worksheet for borders on top of a cell, then loop through until it finds a border on the bottom of a cell (I then perform another call to macro to merge the cells into one). I then loop through all of the used cells to the end where it finds no more borders. code below here. ----------------------------------------------------------------------------- Sub borderloop1() Dim rCell, rCell1 As range Dim lX As Long Do For Each rCell In Selection If rCell.Borders(xlEdgeTop).LineStyle = xlSolid Then Selection.Offset(1, 0).Select ElseIf rCell.Borders(xlEdgeBottom).LineStyle = xlSolid Then For Each rCell1 In Selection If rCell1.Borders(xlEdgeBottom).LineStyle = xlSolid Then MsgBox rCell.Address End If Next rCell1 End If Next rCell lX = lX + 1 Selection.Offset(1, 0).Select Loop Until lX = rCell1.Borders(xlEdgeBottom).LineStyle = False End Sub ---------------------------------------------------------------- with my loop until lX = statement, I tried using UsedRange as my stopping point and it kept going well past my actual used range (it would've kept going all the way to the end of the worksheet had I not stopped at at around row 35,000-- my used range was 62 rows). As I thought about it my goal for a stopping point is to stop at the last bottom border. How would I accomplish that? I received a 91 run time error back stating that the object block or with block variable not set, in using my present statement (Loop Until lX = rCell1.Borders(xlEdgeBottom).LineStyle = False). Thank you. Best. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
looping and stopping when a condition is met - test | Excel Discussion (Misc queries) | |||
Macro - Clear Borders | Excel Programming | |||
Looping thru all rows with instr() test | Excel Programming | |||
Test if cell has diagonal borders | Excel Programming | |||
Using a macro to add borders | Excel Programming |