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
Related
The range "C2": "C82" contains functions of type (='Sheet4'!G38) , (='Sheet6'!G36), (='Sheet5'!G18), etc, that is to say, the cells of this Column C obtain values of calculations that are established in other cells of other sheets. My workbook is constantly refreshed and all its values too. With the help of VBA I would like to remember the previous value that existed in each cell of that column and constantly display it in another column, for example "J2": "J82" every time a refresh occurs. I clarify that what you want to remember are not values entered manually but automatically and that they are funtions. There is a lot of information on the internet, but none has helped me because they only work if the values are manually entered. If they could post the correct VBA it would be very helpful. Note: When I refer to remembering it is because in my Spanish language it is the word that is closest to what I want, in English I think it could also be: obtain, save, record.
Most of the VBA codes I have tried contain: Private Sub Worksheet_Change. Apparently this parameter only detects if something changes, it does not detect when a calculation is made or when a function changes.
Hi I'm trying to write a script in excel that returns a correlating job serial number (which resides on a different sheet) when a cell is filled with the job name.
=IF(D5="Misc",Jobs!A2,IF(D5=1715,Jobs!A3,IF(D5=1725,Jobs!A4,IF(D5=5640,Jobs!A5,IF(D5=6121,Jobs!A7,IF(D5=6150,Jobs!A8,IF(D5="6161-IDC",Jobs!A10,IF(D5="6161-JM",Jobs!A11,IF(D5=6161,Jobs!A12,IF(D5=6535,Jobs!A14,IF(D5="Hudson",Jobs!A14,IF(D5="Berendo",Jobs!A15,IF(D5="Berendo-Move",Jobs!A16,IF(D5="Bungalos",Jobs!A17,IF(D5="Bungalo",Jobs!A17,IF(D5="Camarillo",Jobs!A18,IF(D5="Indio",Jobs!A19,IF(D5="Lillian",Jobs!A20,IF(D5="6161-Beam",Jobs!A21,IF(D5="6161-Roof",Jobs!A22))))))))))))))))))))
The above script does what I need it to do, the problem is I need it copied to 30+ rows with ONLY the "D5" value incrementing. When I hover in the cell corner and drag down to new cells it increments other references besides the "D5" value.
I did a search and replace and manually copied the script to each of the 30 cells to get it functional for now but I'm going to have to do that every time I add a job. I'd like to just add the new job condition and use the fill handle to drag it to all cells, I feel like I need an escape character though to limit what cells are being incremented, I'm just not sure what that would be (it's always going to be column "D", I just need the row incremented to "d6, d7," etc)- thank you in advance for your help!
Seems a case sensitive replacement of A$ for A may be adequate:
=IF(D5="Misc",Jobs!A$2,IF(D5=1715,Jobs!A$3,IF(D5=1725,Jobs!A$4,IF(D5=5640,Jobs!A$5,IF(D5=6121,Jobs!A$7,IF(D5=6150,Jobs!A$8,IF(D5="6161-IDC",Jobs!A$10,IF(D5="6161-JM",Jobs!A$11,IF(D5=6161,Jobs!A$12,IF(D5=6535,Jobs!A$14,IF(D5="Hudson",Jobs!A$14,IF(D5="Berendo",Jobs!A$15,IF(D5="Berendo-Move",Jobs!A$16,IF(D5="Bungalos",Jobs!A$17,IF(D5="Bungalo",Jobs!A$17,IF(D5="Camarillo",Jobs!A$18,IF(D5="Indio",Jobs!A$19,IF(D5="Lillian",Jobs!A$20,IF(D5="6161-Beam",Jobs!A$21,IF(D5="6161-Roof",Jobs!A$22))))))))))))))))))))
I use the auto-fill handle very often; both dragging and double-clicking. I need it, so I don't want to disable it in the options. However, I have certain situations where I'm just trying to copy down values to the next cells, and it appears Excel is using some type of memory/cache to auto-fill them with crazy values. I recognize the values; but there is no rhyme or reason as to why it's auto-filling them at this moment in time.
Example: There are no formulas in any of these cells and this is just a brand new sheet in Excel. I want to grab handle of cell B10 and copy it down to B14:
Now, I wish I could record a little clip of me copying this down so you can see it change the values live, but I promise you, this is what the values get changed to, and it has no relation to the values above it in the same column or anywhere in this sheet and there are zero formulas anywhere; just a simple table being populated:
What can I do to get this to copy the correct values? This has created errors in other tables where I didn't catch it populating the cells incorrectly in time.
My colleague has been suffering this exact problem and his solution is detailed below:
Go into Advanced Options and under General click on Edit Custom Lists button and you should find your values listed there. If so, you can delete them from this list and the problem should go away
Good luck!
I am making a payroll program in Excel and one of my concerns is that the salaries of the employees are searched using the INDEX and MATCH or VLOOKUP function. The problem is if the salaries get updated in the future (e.g. a raise or changes in rates), all the previous entries that used the old salaries will be updated to the new salaries. This is a disaster and would make my entire program useless and inefficient. Therefore I need to automatically lock previous calculated cells after a certain time.
Edit: Note we do not want to do this manually such as copy pasting values only because almost all cells are connected to each other and one mistake by the encoder or if they forget to do this before updating a value, everything will be messed up.
No! Not copying and pasting, there's a simpler way. You want to convert the Formula property of a given cell (what's shown in the formula bar in Excel) into the Value property of the cell (what's shown in the cell on the spreadsheet). For a given range A1:B6 this would done by the statement
Range("A1:B6").formula = Range("A1:B6").value
But there's a quirk in Excel that you can run faster by accessing a Value2 property, so
Range("A1:B6").formula = Range("A1:B6").value2
The rest of the code is left as an exercise for the reader :-)
Update: File
Upon request, I am including the link to the file: here. File no longer available
I have transformed my original data into a game-like context, in which the sheet keeps track of points for completed activities and upon reaching various point amounts, the user goes up in rank. An easy way to see the issue is to enter a 1 (and then 2 and 3) into F15 next to the cell with 500. When you do so, notice how the values in Q5:Q6 change from 0 to 1, but Ranking in C2 which is the SUM function which counts this range does not increase to 3 like it should. And consequently the values in L12 and L14 which are based on it also don't update. Now, if you recalculate, the rank goes up and the L cells update. NOW, cell E3 which is based on the L cells doesn't reflect the correct value, and you have to once again recalculate the sheet for it to update.
Hope all that makes sense - let me know if you need any clarification!
Original Question
Some of my formulas are not updating right away after I have entered in data. Just to get this out of the way before someone suggests it, I DO have the calculation of the workbook set to automatic, and I DON'T open any other workbooks with their calculation method set to manual. So that's not the issue.
I would give specifics on formulas, but I don't think it has anything to do with that. The formula is a simple SUM function which adds together a range. The range updates properly - as soon as I've entered data, the numbers in the range change accordingly. The SUM function should likewise automatically update, but I have to enter data in another cell or press delete in an empty cell (basically, get the sheet to recalculate once again) to get the SUM function to reflect the changes in the range.
The only thing that I can think is that it's because I've enabled iterative calculation (in File > Options > Formulas tab) in order to allow cells to retain their previous value if a certain condition is true, else update their value. My settings are 1 for Maximum Iterations and the default of 0.001 for Maximum Change. However, I've used that before without having issues with a simple SUM function. And I have other just as simple functions in my sheet that DO update properly, so I'm a little confused...
Let me know if any more info would be helpful. Thanks for any suggestions!
UPDATE:
Sorry, I didn't catch that this is for a formula, not function. My bad.
I'll leave the answer up in case someone has the same issue, but with a function. Sorry!
Try adding this inside the code:
Application.Volatile
This will force recalculation for the function each time a cell is changed on the sheet in which this function appears.
Reference: http://msdn.microsoft.com/en-us/library/aa213653(v=office.11).aspx
You have circular references: cell formula in range S4:AL103 all refer to themselves (under cetain conditions). This will cause excel to stop calculating because it can't resolve the conflict.
You wll need to redesign your formulas
Originally added to my initial post; moved it to an actual answer so that it could be accepted
So I figured out the solution. From doing a little more reading up on iteration, I discovered that in iterative mode, Excel processes cells one at a time, in a certain order (alphabetical, I think?). So if cell A is dependent on cell B, but cell B changes value later in the process, cell A will retain a value based on cell B's old value, rather than the new one, until another recalculation is prompted... OR, until another iteration starts. So, setting maximum iteration to a higher number than 1 fixes the issue. Since I had two cells not updating in the example sheet I gave you guys, it would need to be set at about 3. In my actual sheet, I had to set it at 5.
Thanks for the thoughts! Hope this helps some other confused soul!