Thanks so much for this - it works perfectly. What does the ROW($1:$25) do?
See here for general info
ROW function explained | Get Digital Help - Microsoft Excel resource
And here for in context to Ron’s formula
http://www.mrexcel.com/forum/excel-...act-only-numbers-text-string.html#post2194227
_.........................
In the very simplest terms, it produces an Array, “ vertical “ 1 Dimension, of consecutive indices....
{1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25}
_ It is sort of defining here how long the String is that you are wanting to work on / how many “things are compared pair wise” as it were.
_............................
To Demo:
_1) Type that formula =ROW($1:$25) in any cell in a spare sheet.
It will return just 1. That is because although all 25 values are there, you are only giving one cell for Excel to paste out all values to. So it sort of truncates the list only giving you the first value.
After typing that formula in any cell, click on the cell, then click on the Formula bar, select ( highlight ) that formula , then hit F9. - This does an instant Evaluation and so should reveal
{1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25}
( make sure you now hit Esc to get back to the Formula now )
Or
_2) Run this code on a spare Workbook ( for simplicity put the code in a normal macro and select a spare Worksheet. It will then work on that ActiveSheet
Code:
[color=blue]Sub[/color] RowStuff()
Range("A20").Formula = "=ROW($1:$25)"
Range("B20:B44").FormulaArray = "=ROW($1:$25)"
[color=blue]End[/color] [color=blue]Sub[/color]
The first line just does what you did manually to put the Formula in a cell
The second line does the “CSE thing”, which in this case is just telling Excel to put the Values in 25 cells, hence allowing you to see all values.
_..................................
This Evaluate Row ( or Column ) stuff is very powerful and is frequently used to get an Array of sequentially listed indices :
http://www.mrexcel.com/forum/excel-...tions-evaluate-range-vlookup.html#post3944863
https://usefulgyaan.wordpress.com/2...y-without-loop-application-index/#comment-511
( or similar ! )
http://www.mrexcel.com/forum/excel-...-1-dimensional-single-column.html#post4370502
_....
Specifically what is happening in Ron’s Formula is a bit beyond me. But basically if you work through sections of it doing the “click on the Formula bar, select ( highlight ) that formula then hit F9” bit, then that will reveal what is going on..