Naming a dynamic range with blanks - excel

I have a range/list with values per row. Some of the rows are blank.
I want to name the range, and the range should reach the last value (nonblank cell).
So if any cells below the range that become populated, then the range must expand to those cells, even if there are blanks between, like in scenario 2.
Do anyone have a suggestion to how to solve this?

Try below formula which work both for number and text strings.
=Sheet1!A2:INDEX(Sheet1!A:A,MAX(IF(Sheet1!A:A<>"",ROW(Sheet1!A:A),0)))
If you are on Excel-365 then try-
=Sheet1!A2:INDEX(Sheet1!A:A,MAX(FILTER(ROW(Sheet1!A:A),Sheet1!A:A<>"")))

If the non-blank entries in that column are numeric, you can use:
$M$5:INDEX($M:$M,MATCH(88^88,$M:$M))
where 88^88 is assumed to be larger than any numeric within the range.
If the non-blank entries in that column are non-numeric, and none of the blank entries are in fact null strings (""), you can use:
$M$5:INDEX($M:$M,MATCH("Ω",$M:$M))

Related

Sum of index matches for dynamic range of columns

On Sheet2 I am trying to sum the values in a row of a range on Sheet1 over a dynamic range of columns based on a lookup value for the from column and a fixed variable for how many columns to right of that lookup value for the to column.
I am using INDEX-MATCH to find the from cell based on certain reference, INDEX-MATCH with a reference added to the column lookup to find the to column, and CELL to get the position rather than value of the results.
What I have is the following:
=SUM(
CELL("address",
INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)))
&":"&
CELL("address",
INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)+'Control Panel'!$C$2)))
Control Panel!$C$2 is my variable for how many columns to the right of the from column I want the to column to be.
Obviously, this is not working. I suspect it's because the concatenated text in the SUM() reference the full file name rather than 'Sheet1'![from]:[to]. Not sure if this is the case, but also can't figure out how to get just the A1 cell position for the to.
Any ideas how I can get this to work?
Figured it out:
=SUM(INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0))):INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)+'Control Panel'!$C$2))
Literally just needed a colon between the two index-matches. Still not sure why this works, as the index-match should return a value.

Count Numerical Values Separated by Comma

Is there a formula to count the number of numerical values that are separated by a comma in a single cell?
http://support.microsoft.com/en-us/kb/187667
Assuming string in A1:A1... but you can alter to just be a cell or a range...
=SUM(LEN(A1:A1)-LEN(SUBSTITUTE(A1:A1,",","")))/LEN(",")+1
This can be done easily by searching the finding the number of commas in the cell and adding 1.
If the cell you want to search is A1 then use this:
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1

Adding a value to a SUM

I have a row with multiple blank values. I want the answer to be "" if all values are blank. If any of the cells contain a value, I would like to take the SUM of those cells, and add 10 to it. The formula I am using is below, and it always displays the answer as "10", even if all cells are blank. Please help.
=IF(ISBLANK(A1:D1),"",SUM(A1:D1)+10)
ISBLANK() only works on a single cell. You want to use COUNTA() instead.
Counts the number of cells in a range that are not empty
=IF(COUNTA(A1:D1) = 0,"",SUM(A1:D1)+10)

How to switch zeros for blanks in a range in excel?

I need to select a column from sheet1 and the selected column matches destination cell's row. I've got this code
INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1")))
but it selects blank values (empty cells) as zeros insted of empty cells!
I tried to fix it with something like
IF(
(
INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))
)=0;
"";
(INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))))
which of course doesn't work because I'm trying to apply the condition to a range instead of a value.
Is there any way to select the range
INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1")) picking
the blanks as blanks instead of zeros?
Is this what you are trying? I have put your formula inside the TRIM() formula.
=TRIM(INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))))
Note: Trim() will return a string. So if the cell is blank then you will get a blank but if the cell has a number then you will get the number as string
See this Example
I see you may not need an answer any more but I note that your original attempt will work - you can apply an IF to a range, i.e.
=IF(INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))="";"";INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1")))
....but the INDIRECT/ADDRESS combination may not be required, you could return your original array with this formula
=INDEX(Sheet1!$2:$101;0;ROW())
and then just apply a simple IF function to that, i.e.
=IF(INDEX(Sheet1!$2:$101;0;ROW())="";"",INDEX(Sheet1!$2:$101;0;ROW()))
both of those will keep the numeric values numeric

Count number of populated cells in range

How do I count the number of populated cells (with text/number or combinations of text+number)?
I tried =countif(A2:A2000,1=1) (with a general criteria, e.g. 1=1 always) but shows zero (0) for a text column.
I think for the answer above, it should rather be
Application.WorksheetFunction.CountA(Range("A2:A2000"))
I have always faced problems while not mentioning Range, cause it considers the whole range to be as a single unit.
The formula is =COUNTA(A2:A2000) : non-blank cells are counted.
In VBA it's WorksheetFunction.CountA("A2:A2000")
Dim Coloumncount As Integer
Coloumncount = Application.WorksheetFunction.CountA([D1:D100])'count how many filled cell in coloumn "D"

Resources