PDA

View Full Version : Meaning of iLastColumn = .Column + .MergeArea.Columns.Count - 1



kewiopex
12-14-2016, 09:09 AM
Dear Specialists
I have tried without success using google and related searches to source the meaning of the expression

1. iLastColumn = .Column + .MergeArea.Columns.Count - 1

2. and particularly with what .MergeArea.Columns.Count actually counts (all the columns covered by all the merged cells or just the count of the merged cells?

Any help would be appreciated.

SamT
12-14-2016, 11:13 AM
The lower case "i" in "iLAstColumn" indicates that the Variable iLastColumn was Declared as an Integer. All Column and Row counters should be declared as Long since the possible number of columns and rows is larger than an Integer Type variable can handle.

The "dot" in ".Column" means that it is referring to the Object in the previous "With" Statement. Without knowing Which Object that is, it is impossible to fully understand the code you show. ".Column" is the number of some Column belonging to the unknown "With" Object.

"MergeArea.Columns.Count" does indeed Return the number of Columns in the MergeArea Object

All Range Objects have a Column Property.

MergeArea is a Property of a Range Object that is a member of some merged cells. It returns a Range Object that is all the cells in the merged cells.

The Column Property of a MergeArea Object is the number of the first column in the merged cells group.

Now, I am speculating. . .
The "With" object is a cell in a block of merged cells.

".Column" is the number of the first column in the merged cells block.
That would make
iLastColumn the number of the last column in the merged cells block.

If ".Column" = 3 and "MergeArea.Columns.Count" = 5, then "iLastColumn" = 7

kewiopex
12-14-2016, 11:56 AM
Thank you once again SamT for your timely response. Now...I understand! I was not sure about the mergeareas.column count did actually count the actual number of columns occupied by the merge cells.

When you speculated that the object was a With, you are entirely correct that it refers to a block within the merged cells.

I am applying this expression in support of a function and tryng to get it to work and determining the reasons why it is not.

Cheers!