Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default "for each...next" and adjacent cells

Hello all,

My question reflects a poor understanding of the nature of cells,
ranges, etc.

I´m working on a macro to scan a worksheet for cells that are
underlined and then adjust the merging, alignment, etc. of those
underlined cells. Right now, I´m stuck trying to identify the
left-most of a group of adjacent, underlined cells. I have a
(working) function to test whether a side of a cell is lined or not,
so what I´d like to be able to do is say:

IF cell has bottom border AND the cell to left does not have bottom
border THEN ...

I´m using the "for each ... next" to loop through the cells, and I
would like to know how to reference adjacent cells using this
technique.

The relevant part of the code is as follows:

--------------------------
Sub FindUnderlinedCells()

Dim r1 As Range
Set r1 = Worksheets(1).Range("A1:G300")

For Each c In r1

If CellTest(c, "bottom", True) And _
CellTest((Worksheets(1).Cells(c.Row, (c.Column - 1))), "bottom",
False) Then
ModifyBlanks (c)
End If
End Sub
------------------------

As you can guess, the part that doesn´t work is the first argument of
the second call of the CellTest function.

Thanks in advance for any help!
-Andrew
Reply
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
Adding data only if adjacent to cell labeled "male"/"female" lovesrubbaducky Excel Worksheet Functions 1 November 23rd 09 05:49 PM
how can I disable "cutting cells" and "drag and drop "in excel ? mwoody Excel Worksheet Functions 4 August 25th 08 03:53 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Check if cells contain the word "Thailand", return "TRUE" ali Excel Worksheet Functions 7 September 14th 07 09:53 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 11:45 AM.

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

About Us

"It's about Microsoft Excel"