ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   More on merged cells (https://www.excelbanter.com/excel-programming/315727-more-merged-cells.html)

Frank Rizzo

More on merged cells
 
I loop through the cells in a range and sometimes, the cell will be part
of the merged area. How do I find out whether the position of the cell
within the merged area? For instance, if the cell is 2nd from the top
and 5th from the left. How do I find out this information?

Tom Ogilvy

More on merged cells
 
Dim rng as Range, cell as Range
Dim offsetrw as long, offsetcol as long
set cell = Range("B9")
set rng = Range("B9").MergeArea
if rng.Count 1 then
offsetrw = cell.row - rng(1).row + 1
offsetcol = cell.column = rng(1).column + 1
msgbox " row offset: " & offsetrw & vbNewline & _
" column offset: " & offsetcol
End if

--
Regards,
Tom Ogilvy


"Frank Rizzo" wrote in message
...
I loop through the cells in a range and sometimes, the cell will be part
of the merged area. How do I find out whether the position of the cell
within the merged area? For instance, if the cell is 2nd from the top
and 5th from the left. How do I find out this information?





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com