Finding the Last empty Row within a table using .rows.count confusion - excel

I have a table with a List of data in it. I have chosen
ws.Cells(ws.Rows.count,"A").End(xlUp).row
to find the first cell that is empty within column A.
The problem is that the code outcome is stuck on the length of the table despite having empty cells before the end table length. Clearing all cell formats and content within the table has not worked.
Does this particular code recognize the table element as cell occupancy? Or am I missing a portion of code? Thanks a bunch

ws.Cells(ws.Rows.count,"A").End(xlUp).row will find the last non-empty cell in column A.
To find the first empty cell in column A (assuming cell A1 itself is not empty) you could use:
ws.Cells(1,"A").End(xlDown).row + 1

Related

How can I keep the same cell reference in if function, until the if function is true/false?

I have the following function in excel:
INDIRECT(CHAR(COLUMN()+53)&O1+1)
This function has to be the outcome of an if-statement when the statement is true. I don't want the O1 to change to O2, O3, etc.. when I drag the function down, until the statement is true. From there I want the function to change this cell reference in ascending order. So as long as the if statement is false, the reference needs to be O1.
I know that absolute referencing can be used to keep the same cell-reference ($O$1), but then the cell reference doesn't change when the statement is true either.
My data looks like this: enter image description here
My complete formula looks like this: enter image description here
=IF(P2=INDIRECT(CHAR(COLUMN()+51)&O1+1);IF(INDIRECT(CHAR(COLUMN()+51)&O2+1)="";INDIRECT(CHAR(COLUMN()+53)&O1+1);INDIRECT(CHAR(COLUMN()+51)&O2+1));IF(INDIRECT(CHAR(COLUMN()+53)&O2+1)="";"";INDIRECT(CHAR(COLUMN()+51)&O2+1)))
What I want to do is to fill a column with values of the first column in the data until the cells are empty. Then I want to fill the column with data from the i+2th column (so from column C I go to column E). In order for this to happen, I want the first cell of (column E in this case) to stay the same, until column C is empty and the column starts taking values from column E.
I hope that this description gives a clear view of what I want to do.
Thanks in advance.
What I want to do is to fill a column with values of the first column in the data until the cells are empty. Then I want to fill the column with data from the i+2th column (so from column C I go to column E). In order for this to happen, I want the first cell of (column E in this case) to stay the same, until column C is empty and the column starts taking values from column E.
It's not the same kind of solution, but this might suit your needs better than your original formula:
=
IFERROR(INDEX(OFFSET($A$1,2,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,2,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
""))
If you need it for more than 2 columns, just extend the formula by following this pattern:
=
IFERROR(INDEX(OFFSET($A$1,2,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,2,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
IFERROR(INDEX(OFFSET($C$1,2,0,COUNTA(C:C)-1,1),ROW($A1)+2-COUNTA(A:A)-COUNTA(B:B)),
IFERROR(INDEX(OFFSET($D$1,2,0,COUNTA(D:D)-1,1),ROW($A1)+3-COUNTA(A:A)-COUNTA(B:B)-COUNTA(C:C)),
""))))
Sample implementation: https://i.stack.imgur.com/MAtxW.png
I've made considerations for your extra blank row between the header and the first row of data. For anyone wanting to use this formula without the blank row in their data set simply change the Offset-Row parameter from 2 to 1:
=
IFERROR(INDEX(OFFSET($A$1,1,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,1,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
""))
You can stick the formula anywhere in your worksheet, but don't forget to change the column letters to suit the location of your fields. In your case, probably:
=
IFERROR(INDEX(OFFSET($C$1,2,0,COUNTA(C:C)-1,1),ROW($C1)+0),
IFERROR(INDEX(OFFSET($E$1,2,0,COUNTA(E:E)-1,1),ROW($C1)+1-COUNTA(C:C)),
""))
Be aware that you need to make sure your columns don't contain rows with blank cells in between names, as this will cause it to skip an equal number of names at the bottom of the column.
EDIT:
I just realized your system uses semi-colons ";" to parse Excel formulas (mine uses commas ","). Please take note of that when copying these formulas to your spreadsheets. Here's the formula again but using ";"...
=
IFERROR(INDEX(OFFSET($C$1;2;0;COUNTA(C:C)-1;1);ROW($C1)+0);
IFERROR(INDEX(OFFSET($E$1;2;0;COUNTA(E:E)-1;1);ROW($C1)+1-COUNTA(C:C));
""))

Excel Check for multiple value in one row within a range

I have a spreadsheet with thousands of rows and numerous columns. What I am hoping to accomplish is to basically check column AB for a certain value. When it finds a row that contains (not exact match, just needs to include) the word "test" then I want to check if column Z (in the same row) has value "next". If both those are true, then I want to display the value from column N in that same row. What code could I use to accomplish this?
Note: I need this to list the value from column N for each row that has both "test" and "next", not just for one row.
Edit:
To clarify what I mean by multiple values see this image:
I want a formula that will list ALL of the Column N values of rows that meet have both test and next. And this list is not in the row, it is going to be one column listing each match.
Update:
I have gotten close to getting this done, this is my best formula up to this point. =ArrayFormula(IF(ISNUMBER(MATCH("*"&$A$1&"*",SID!AB:AB,0)),SID!N3,"n")) This works once, but here is what I need fixed:
This returns the first value that works, in this example Place1, but then it just lists everything form column C, even if it does not reach the requirements. Most likely an issue with my arrayformula.
Try out the below formula,
=IF(AND(ISNUMBER(MATCH("*"&"test"&"*",A1,0)),ISNUMBER(MATCH("*"&"next"&"*",B1,0))),"Column N value","")
This formula searches cell A1 for the string test (anywhere in it) and searches next in cell B1. I leave the part of replacing the cells with the required columns to you and also change the Column N value in the formula to N1

Return the column header of last cell with data

I'm working on a spreadsheet and trying to create a formula to count the last cell with data, then return the column heading for that cell.
There are two parts here:
Find the first cell with data, return the column heading
Find the last cell with data, return the column heading
I've solved for 1 by the following:
=INDIRECT(ADDRESS(1,COLUMN((INDEX(H223:S223,MATCH(TRUE,INDEX((H223:S223<>0),0),0))))))
But I haven't been able to solve for the second part. I found the following solutions online, but they aren't quite right...
=(ADDRESS(ROW(H223:S223)+ROWS(H223:S223)-1,COLUMN(H223:S223)+COLUMNS(H223:S223)-1))
^ Returns the last cell reference of the range, does not check if cell has data or not.
=LOOKUP(2,1/(H228:S228<>""),H228:S228)
^This one is a bit more promising. This formula returns the value of the last cell with data in the range. But I can't get LOOKUP to work with INDIRECT/ADDRESS/COLUMN functions which I used for the first formula.
Can anyone help me out? Thanks!
FYI - the column headings are months and cells are $ projections. These formulas are supposed to help me understand how $ flows by month for the next fiscal year.
=LOOKUP(2,1/(H228:S228<>""), H228:S228)
' ^^^^^^^^^^
Your LOOKUP formula is a good idea, but needs a slight modification to return a value from the header row instead of the investigated row:
=LOOKUP(2,1/(H228:S228<>""), H1:S1)
' ^^^^^^
To return the column header of the last cell with value, use the following:
=IFERROR(INDEX(H1:S1,MAX(IF(LOOKUP(2,1/(H228:S228<>""),H228:S228)=H228:S228,COLUMN(H228:S228),0))),"")
Array Formula press Ctrl+Shift+Enter at the same time
Array formula in case you have duplicates
H1:S1 is the Header Row
H228:S228 the last row with data
Lookup will find the last cell with data
Index will return the corresponding header

How to go through empty excel cells and selectively use function (or a work around)?

http://i.stack.imgur.com/JrsH7.png
I have on excel what is shown above. What I need is to fill in the Row and Column columns with the values in the head of the column that the value to their left is in. What this means is that for D001-01 the Row value is 1 and the column value is also one.
For D001-02 Row=1 Column=2
For D001-03 Row=1 Column=2
For D002-01 Row=1 Column=1
And so on. Is there any good way I can do this? My real lists are very long, this is just a simplified example.
You can use the MATCH function, searching for "*" to get any non-empty cell, to get a number for the column that is not empty in the row. Then, you can use the INDIRECT function to convert that into a reference to the corresponding column heading. Then, use FIND to find the index of the 'X' along with LEFT to get the row value or RIGHT and LEN to get the column value.

Large excel file, I'm trying to find duplicates and copy the rest of the cells across the duplicate to the duplicate it finds

I have a large excel file, it has 65,000 parts, those part numbers are in column A. Then it has several columns of important info next to the part number (B is retail price, C is my cost, D is the weight, E description and so on until J)
I was just given a list of 16,000 new parts, they are superceeded from old parts, all the new list tells is new part number in column A and old in column B.
So what I can't figure out is how to tell excel if B65001 matches anything in column A1-A65000 then copy the information from the columns next to that A cell into the columns next to this duplicate.
I hope that makes sense?
Please help
I would:
Put the list of new parts in a new sheet (let's call this "Sheet2")
Sort this by column A (required for the VLOOKUP function)
Insert a column next to A in the original sheet
Put the formula =ISERROR(VLOOKUP($A2, Sheet2!$A:$B, 2, FALSE), $A2, VLOOKUP($A2, Sheet2!$A:$B, 2, FALSE)) in column B2 of the original sheet (the new column, and I'm assuming you have headers), and fill it down
Copy this new column and paste it over itself, but select Paste Values from the Ctrl paste options menu. This will get rid of the formula and solidify the new part number as text.
Delete the old A column and the new B column will take its place.
Delete Sheet2 if desired.
The formula in layman's terms: Excel will search for the old part number in Sheet2. If not found, it will produce an error, and just use the old number. If found, it will use the value next to the old part number on Sheet2, the new part number.
An explanation of the VLOOKUP function:
The first argument is the value to search for. In this case the value in the A column of the same row (fill-down will automatically change the "2" accordingly)
The second argument is the range to search in. Excel will look in the first column of this range for the value, and it MUST be sorted.
The third argument is the 1-based index of the column to return. In this case, you want the second column.
The final argument determines whether to return the nearest match (TRUE) or only exact matches (FALSE). You want the latter behavior.
VLOOKUP in this mode will produce an error when a match is not found (specifically #VALUE when the value would come before the first instance of the table, or #N/A if the value is not found in exact-match mode)
Copy the Column in other sheet into you want to search Duplicates,, & write this simple formula but break the database in parts to avoid system delay,,
=IF(COUNTIF($A$2:$A$8, $A2)>1, "Duplicate", "")
Use this array formula to count Duplicates,
=ROWS($A$2:$A$8)-SUM(IF( COUNTIF($A$2:$A$8,$A$2:$A$8)=1,1,0))

Resources