I have an excel sheet that is being fed data from a userform. Certain cells auto update based upon when certain cells on the Home page or Setup page change.
On the setup page, cell H1 references cell Home!B15 which is control sourced to my userform. It takes in a sales rep name.
Cell H2 has the following formula
=IF(ISERROR(VLOOKUP(Home!B15,D2:E243, 2, FALSE)), "", VLOOKUP(Home!B15,D2:E243, 2, FALSE))
This works fine!
In cell Home!B16, I have the following formula
=Setup!H2
For whatever reason, it will populate the correct value one time. Once I select a different sales rep in my userform, it loses the formula, and keeps the first value.
My question again: Why is my cell losing it's formula after taking on its first value?
I have encountered the same issue with a userform in VBA/EXCEL 2010. It seems when you change a value in the form that affects the value in a calculated cell, the formula in that cell gets replaced with a literal value. Pretty frustrating.
The best I could do for a workaround it to store the formulas that get lost in another location (in a dictionary object, for example) and then when I close the form I use VBA to overwrite the [new] literal value(s) with the formula(s) that were in those cells to begin with.
Related
Got a formula (shown below) that I am trying to apply to Microsoft form answers. Microsoft forms appears to automatically insert a new row with every submitted answer which prevents the formula from working on the correct referenced cell. Is there a formula on Microsoft excel online that will reference correctly when the form inserts a row?
If I manually drag formula down it updates properly and shows correct cell reference. Tried importrange and query to link the data from the form excel sheet to another sheet but these functions aren’t included on excel online. I also tried indirect function but I could not modify my existing formula to work with it.
=IF(RAW!M2<>””,RAW!M2,””) This formula transfers data from “RAW” data sheet to a separate sheet and leaves cell blank if no entry is found in the source cell.
If inserting rows breaks references, you can use Index with a row number.
Instead of
=IF(RAW!M2<>"",RAW!M2,"")
use
=IF(Index(RAW!M:M,row(A2)<>"",Index(RAW!M:M,row(A2),"")
When copied down, the reference to A2 will change from A2 to A3 and so on and the returned value will change accordingly. The formula will always return the value from row 2 if the formula references Row(A2), regardless of rows being inserted or deleted.
I cannot post my code because it is company property, but the issue is that I would like to enter a cell formula so that it automatically updates when particular other cells change.
I have two columns, one for prices in USD and another for another currency. The other currency column is a simple "=SUM..." but the currency conversion to USD is always changing, and the prices are large enough that these changes matter. As such, I have the user enter the conversion value in the activex textbox, and I want to set the formula of the USD cells to be the price in USD, so obviously I need to get this conversion value, but I cannot just type in the textbox name, that does not work.
I am using VBA, but I would like to enter this directly into the cell as "=FORMULA", where formula contains the activeX textbox value, so that it automatically updates.
As far as I have found in VBA, if I want to assign a formula to a cell, I have to do so within a sub or function, so I have to call the sub every time I want to update the cells, but I want this to be as automatic as Excel is for other cell formulas.
I have been playing with Worksheet_Change and considered worksheet_open but have had other issues. For example, there are many different cells that could change that I have to monitor for change, and I cannot simply monitor the price column in the other currency for change because when cells update from a formula, Worksheet change does not show those cells as having changed.
Maybe this is as simple as setting the cell formulas on worksheet_open, but I also have not had luck with getting cell.formula to even work. I could discard the textbox for a regular cell which would totally solve this problem, but I also have a textbox_lostfocus sub that I need to run, and I don't know how to do that for a cell.
Sorry for the long post, in summary, how can I assess a textbox value for use in a cell formula ideally without using vba?
This is what linked cells are for. You link your ActiveX textbox to a cell. The cell value then gets updated once you update the value of your textbox. You can reference this cell in your normal excel formulas. See here for a tutorial: https://analysistabs.com/vba-code/activex-controls/textbox/
I am trying to create a vocabulary quiz in excel, where a correct answer is the only possible input into a cell. So far, I use data validation to ensure that outcome, but cannot figure out a way to batch edit data validation. I want every blank cell's validation to equal the adjacent cell, which contains the correct answer. I was hoping that copying one correctly formatted cell and pasting it in an empty cell would cause the new cell to reference the new adjacent cell, but have found that the new empty cell still validates according to the old cell. In other words, I would like the cell's data validation to copy and paste sequentially, like when you drag a cell containing the number 1 and the cells below populate with 1, 2, 3, etc.
This is a problem that has to do with efficiency. I could accomplish what I want by data validating every cell to its adjacent "by hand," but it takes a very long time with large amounts of data. I've tried conditional formatting as well--a correct answer turns the cell green--but have run into the same problem.
Any help would be greatly appreciated.
Thanks.
Not sure how you did the copy/paste, but it should work fine. Here is an example.
Set up the initial data validation. I am using the List version of it with a single cell reference. Note that the single cell reference is defined relatively (no dollar signs in it). I removed the In-cell dropdown option so the answer isn't visible!
Now if I copy that cell and paste one cell below, it will apply the data validation with the range updated. I did this with a simple copy of C6 and paste into C7. I changed the value to b after the paste to not get the error. When I open the validation for C7 I see the new range (D7).
You can paste to a larger range than 1 cell and it will update all of the references accordingly.
I am trying to develop a spreadsheet pulling data and text from another sheet within the workbook while leaving the cell blank if not populated in the aforementioned sheet.
I am trying to develop a materials summary sheet pulling from a stock transfer sheet.
In the initial column, I have inserted the formula =IF('Stock Issue'!D13,'Stock Issue'!D13," "). This works fine in that if the cell in Stock Issue is populated, the quantity inserted is pulled into the new spreadsheet and if not, it is left blank.
I tried duplicating this formula in the next column for Quantity and the result I get is #VALUE!
Since this cell is populated with text (i.e., EA, LF, SF, etc.), is that the issue? How can I populate with text?
Thanks
You need to test whether the cell is blank:
=IF(ISBLANK('Stock Issue'!D13),"",'Stock Issue'!D13)
I have the following formula on various sheets in an Excel workbook:
=SUM(SUMIFS(INDIRECT(CONCATENATE("'",REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),"")," HR","'!$e:$e")),INDIRECT(CONCATENATE("'",REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),"")," HR","'!$q:$q")),I$13,INDIRECT(CONCATENATE("'",REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),"")," HR","'!$j:$j")),{"שעון","בתפקיד","עבודה מהבית"}))
the formula takes the name of current sheet, concatenates the string " HR" to it and goes to a range of cells in sheet named as the concatenated string.
It performs a few calculations on the data there and returns the value.
For some reason the cells in different sheets that contain the "same" volatile formula show me the values that would come up in another sheet.
To see the right value I must enter only one of the formulas boxes in a relevant sheet, press enter and the evaluation turns to be correct.
I tried formula evaluation and theoretically it shows me the right calculation process on every sheet.
Any suggestions? Could it be some evaluation issue that is not related to formulas correctness?
You expect CELL to return information on the current cell when no reference is given, but it does not. CELL returns values based on the ACTIVE cell -- the cell that is active at the time of the calculation. Every time the cell recalculates, it will look at the active cell at that time, which may be on another sheet.
To see this in action, use the formula =CELL("address")&" "&TEXT(NOW(),"hh:mm ss") Since NOW is volatile, the cell will be recalculated every time you edit a cell. Edit any other cell, and you will see the address of that cell and the time it was calculated.
You will almost always want to include a reference value, eg CELL("filename",A1) To get the expected behavior, you'd just use a relative reference to the current cell.