LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default looping macro to test for borders

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping and stopping when a condition is met - test april Excel Discussion (Misc queries) 1 October 21st 09 11:36 PM
Macro - Clear Borders Jim Thomlinson Excel Programming 4 November 21st 07 10:04 PM
Looping thru all rows with instr() test Silvertip Excel Programming 6 November 1st 05 02:29 PM
Test if cell has diagonal borders Brad Excel Programming 4 September 30th 05 01:36 PM
Using a macro to add borders Colin Foster[_3_] Excel Programming 1 October 19th 04 07:14 PM


All times are GMT +1. The time now is 04:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"