Form scrolling to last row instead of next - excel

I have a table (1000 rows) and I am using a form to insert the data. When I open the form for the first time and enter in a record it works, the record gets inserted in the first row. Then when I press the "New" button when I enter the next record instead of it being inserted in the next row it gets inserted in the last row (1000th row) of the table.
I have no idea why. I thought the form would always enter in the next available row. PS I am not sure if this is important but I do have functions I use in some columns e.g. =IF(I2="b", SUM(B2:F2),"")
Can anyone explain why this is happening please and how to ensure the "next" record goes into the "next" row?

Try using Enter instead of "New".
It seems likely that you have already identified your problem - ie that the formula has already been automatically copied down in your table, hence the records (even if formula only) already exist - so the next new one is 1000.
Until I2 is populated (and perhaps not even then) the formula returns a blank, so will not be evident - but is lurking for when required!

Related

Datagridview and DataError

I am using a DataGridView with a dataset as a source. I have setup a dataset within visual studio and it all works well.
One column is an integer and if you enter something that is not, the DataError event fires and lets me know. Great! (e.context is 768)
Another column is a string, but unique. Again the event fires but there is a difference.. (e.context is 512)
The Integer column fires as soon as finish editing the cell.
The String column with unique only fires when I click off the row, not the cell.
The issue is the e.Column index doesn't relate to the cell with the error. It is what ever I click on.
I had previously used a manual way of checking for unique values, but had hoped this more automatic way would suit better. Is there any way to get the DataError to trigger after every cell?
Is there another way to work with unique values?
Many thanks
EDIT
Sorry if I wasn't clear...
If I have a INT column and I put a letter in as soon as I confirm the value (press enter/click out of the column) I get the DataError trigger.
If I have a STRING column set to Unique if I then enter a value that already exists in the column I only get the trigger once I confirm the ROW (click off the row)
I feel manual coding might be easier and then I can make it work exactly like I want!
Does that make sense?
Cheers

Array formula not updating until enter is pressed again

This question can, I guess, be part of the same problem mentioned in another question that I have asked a couple of days ago.
My problem is that I have an array formula that looks in a table for cells containing FAIL. Basically, if there is a FAIL in the table, the array formula returns the line of the fail if there is none it says No failure.
But I also have buttons running some macros that filter the data in the same table (but do not remove the FAIL). When I click on the button/run the macro the macro display No failure which is not correct. However if I press ctrl+shift+enter (without changing the formula) it updates to the correct value (being the line of the FAIL).
So in a nutshell my array formula is not updating until I press ctrl+shift+enter a second time and i don't know why.
Refreshing the sheet, closing-opening again, or using the calculate now function do not work.
My formula (fairly messy I admit haha) is:
=IF(TEXTJOIN(",",TRUE,IF((Table1[Load Pass fail]="FAIL"),IF(NOT(ISBLANK(Table1[Measure])),ROW(Table1[Load Pass fail]),""),""))="",IF($E$23="","Not run","No failure"),TEXTJOIN(",",TRUE,IF((Table1[Load Pass fail]="FAIL")*(NOT(ISBLANK(Table1[Measure]))),ROW(Table1[Load Pass fail]),"")))
If you can help me thank you in advance.
EDIT: it appears that when I change one of the value in the parts of the table targeted by my array formula it triggers the formula and it goes back to the correct value.

Update dynamic drop-down list in excel without VBA

I want to create 2 dependent drop-down lists in excel, first drop-down value decides what value has to be displayed for the second dropdown.
Used following OFFSET formula for second dropdown values to get populated dynamically.
=OFFSET($B$2,MATCH($G$3,$B$3:$B$17,0),1,COUNTIF($B$3:$B$17,$G$3),1)
. I have also prepared a sample file showcasing the formulas I have used.
When I select first dropdown value, second dropdown list gets updated. BUT, when I select another value in first dropdown, second list doesn't showcase the values immediately.
Sample file link - https://drive.google.com/file/d/1rwt6B-INgrQ0NgxIl-Nc8JeoGziBaiL2/view?usp=sharing
Now that's what I call a challenging request.
We will use the secret Evaluate formula to achieve this.
Disclaimer:
Ensure that a status never get separated from its peers (e.g. do not add another New at the end of the table, rather insert a column so that statuses stay in packs).
Note that changing status will not clear the definition cell. Simple VBA will do the trick (and that is the only place where you will need VBA).
Solution:
Let's create a formula that returns a the address of the range we want to use in the dropdown. You can paste that it I3.
=ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0),0)), COLUMN($C$2)) & ":" & ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0)+COUNTIF($B$3:$B$17,$G3)-1,0)),COLUMN($C$2))
If I made no mistake with my French Excel, you should get the address of all the definitions for the status you put in G3. Extend the formula a few rows down and you will see it always matches G4, G5 and so on.
Time to define a Name (Menu Formula > Name manager > New), that we will call DynamicRange.
First, I would recommend to change the scope to your worksheet (Dropdown in the window).
Next, put the very formula we tried before, but in an EVALUATE.
=EVALUATE(ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0),0)), COLUMN($C$2)) & ":" & ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0)+COUNTIF($B$3:$B$17,$G3)-1,0)),COLUMN($C$2)))
Here what it looks like (except I'm all in French ...)
Go back to data validation and in the list's source, simply type =DynamicRange
The list is easy to define once the above was done successfully.
I see what you are trying to accomplish (get the second cell value to auto update to the first list entry), but I do not think it is possible without using VBA.
My understanding is that "Data Validation" only verifies the data within the cell, it does not change the existing value.
If you want to change the existing value, then I would look into VBA.

Excel table default value and data validation without VBA

I have a table in Excel for tracking projects. Whenever I create a new row for the table I'd like it to auto-populate one column that the project has "Not Invoiced". I would ALSO like that this column use Data Validation to only allow either "Not Invoiced" or "Invoiced" as content.
I have been able to make both of these things work, but I cannot seem to make them work together without error! The closest I have gotten:
Put a formula in the relevant column. Have tried both the super basic ="Not Invoiced" as well as an =IF formula based on the blankness of another column. This correctly carries down each time I make a new row.
I then add Data Validation on the column which also works fine at first since my default value from my formula is one of the options, HOWEVER when the project does invoice and I select "Invoiced" I then get an error that I'm violating the above formula. From what I've read selecting something from the drop down should just replace the auto-populated formula, but that doesn't seem to happen, it gives me an error that I've violating the column's formula instead.
I've read multiple places that if you correctly order things (create table, add formula for default value, then add data validation) the above method should work, but it will not for me and I continue to get the error every time I change to "Invoiced".
you can enter the stati "Not Invoiced" and "Invoiced" into cells that are close together, e.g. $G$3 and $G$4. Then, create a named range for $G$3:$G$4, let's say "ValList" (menu: Formula / Define Name).
Imagine column A to be the controlling column, and B the status column ("Invoiced" / "Not Invoiced"). Example for cell B5:
The initial status is =IF(A5=""; ""; $G$3)
The Validation (type "List") must be controlled by a formula =IF(A5=""; " "; ValList)
Good luck!
There's a simple way to do this.
Before you start using a new table, add list data validation to the cell in the first and only row:
Invoiced,Not Invoiced
Then, in the first row of your table in that same cell write:
=IF(TRUE,"Not Invoiced";"Not Invoiced")
This will put Not Invoiced as the default value on every new row that is added to the table and also keep data validation in place. You will still have access on every new row's cell to the dropdown list stored in the initial cell's data validation list parameter.
For some reason, data validation is overwritten if you try the same IF-function approach in reference to another cell, as you described it.
One way to solve this would be to use a helper column.
You can use the data validation list for the entry column, say column A.
You can use a formula in the hidden column B with the formula =IF(A1,"Invoiced","Invoiced","Not invoiced")

Deleting rows in excel without affecting the Excel formula

I have a spreadsheet where Iam trying to add the serial numbers in each row using the below formula
=IF(C149<>"";MAX($B$149:OFFSET(B150;-1;0))+0.1;"")
However, whenever I delete the rows in B column there will be error value in all other rows like #N/A
Whether it is possible to delete the rows without affecting the Formula ?
I heard there is a excel function "INDEX" to be used, please reply with your answers how to apply INDEX function to the above Formula
Not exactly the answer you were asking for, but google picks this out for deleting without breaking formaulas - so anyone landing here from google...
The formulas break because you are removing cells from the spreadsheet - chainging the structure of the sheet. Where as what you want to do is just remove the data, and have all the remaining data move up.
One way is to select all the data below the line you want cleared (plus one blank line at the end) - then copy that range (to the clipboard) and paste it all back in one row higher.
Not a great solution - but it works - I found this question looking for a better way! :)
The issue could be related to $B$149 When you delete a row the $ means that the 149 cannot change accordingly like the C149 and B150 would , this may then mean that it is pointing to incorrect data after the deletion.

Resources