Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding data only if adjacent to cell labeled "male"/"female" | Excel Worksheet Functions | |||
how can I disable "cutting cells" and "drag and drop "in excel ? | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Check if cells contain the word "Thailand", return "TRUE" | Excel Worksheet Functions | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |