i have a simple question but i can't find an answer in google.
i have the following simple code:
cells(1,1)= cells(1,2) + cells(1,3)
i want to be able to show the user the result in cells(1,1) but that he can also see how i got it (if he stands on the cell he should see that i did =B1+C1).
how can i do it?
moreover, i want him to be able to change the numbers in B1,C1 and get a new result in A1 like regular he could do in regular excel function
how can i do it?
thanks!
I think you may want to just add a formula to the cell and not put in a value.
Check this out.
VBA To Add Formula To Cell
Not exactly what you are asking but it shows you how to add a formula in your vba code.
Related
My first post here, maybe someone will be able to help.
I have a large Excel table with data from labs. Some results are below LOD And I need to remove them as I do not need them.
So basically I need to clear data in one cell, say E11, if data in D11 shows "<". Meaning below LOD.
If possible I would like to replace value in E11 with "-".
Is there any one who could help me please.
There are a few ways to go about this and you don't really need VBA.
Without VBA - Create a filter on your results and simply filter away the "<" - you could copy and paste this filtered table to another sheet
You could use a cell formula to help you identify results: =IF(A1="<","",B1) which would look at A1, if A1 was a < then it'd return nothing, otherwise it'll return value in cell B1.
With VBA - you'd basically be applying the same logic, just written in code. If you really want to do this, then look up how to do a loop first and how to use IF logic...
enter image description here
This is the worksheet I work with. I would like to clear all the values where < is next to them. This is just part of much bigger table.
I m new to Excel VBA. i need to do a vlookup in excel sheet with this vlookup formula:
=INT(IFERROR(VLOOKUP(A:A,[sheet.xls]Sheet1!B:F,5,FALSE),0))
Could any one guide me to apply this vlookup using VBA
Basic approach:
myRange.Formula = "=INT(IFERROR(VLOOKUP(A:A,[sheet.xls]Sheet1!B:F,5,FALSE),0))"
It could be worth that you give also a look at .FormulaR1C1 property which might be more explicit from VBA. If you don't use FormulaR1C1 syntax, pay attention to Absolute/relative address.
mySheet.Range("X2").Formula = "=INT(IFERROR(VLOOKUP($A:$A,[sheet.xls]Sheet1!$B:$F,5,FALSE),0))"
If you don't know how to do something with VBA, use the Macro Recorder. Its output is crappy and always needs to be cleaned up, but at leat you get an answer in 5 secs and it's an easy learning tool.
Eventually, enter the formula manually in a cell - say in X2 - then from the Immediate window, you type Print range("x2").Formula (or formulaR1C1) to see the exact formula to put in your code.
With the cell A1 containing a formula saved as string. Ex: Sum(B1:B5)
In A2 I want to execute content of A1. But when I put =(=A1) in A2 excel gives me formula error. Is there any way I can execute content of A1 in A2 as formula
Mind you no VBA is allowed. Can someone please help?
Please only those people should answer who have done this thing in the past. No hit and tries please
=A1
that's all you need to point the value to the value in cell A1
With VBA :
with VBA you can write some custom function and then evaluate the formula.
Then call the function in excel wherever you required like below
=eval_formula(A1)
Function eval_formula(fr)
eval_formula = Evaluate(fr.Value)
End Function
Refer the link here for more details
https://superuser.com/questions/253353/excel-function-that-evaluates-a-string-as-if-it-were-a-formula
without VBA:
Create a named range and use the named range inside the cell, I have attached the screenshots for your reference
hope this is what you required.
The Evaluate function doesn't exist in Excel anymore.
The only way you can use to evaluate properly is unfortunately only VBA.
In addition to the good answer of Durgaprasad. Here are some other ways to evaluate in the related question:
How to turn a string formula into a "real" formula
I want to write somthing in cell A1 and it should get replace with A1*100 automatically. Can we do this?
e.g. If i type 23 in Cell C2, then this value should get replace with (C2*100)
You are looking for something like this. It gives a good outline of how to trigger a macro when an event happens, like changing the value of certain cells. There is also this, from Microsoft that explains Worksheet.Change(Target).
I want to create a summary file where I wish to import the data from cell D11 from some workbooks. For this I try to use INDIRECT to call the workbook O284, where O284 through O296 consists of strings like:
2015-01 (for O284), 2015-02 (for O285 etc)
and where O285 is the sheetname, which is consistent for each workbook hence the $$'s.
=INDIRECT("'C:\Path\["&O284&"]"&$O$285&"'!$D$11")
Running this however does not return a value, but merely a ####. I have all the workbooks opened. I suspect I conduct the INDIRECT snippet wrong, but I can't figure out how. Does anybody have a clue?
Regards,
Btw, is there a way to achieve the same thing as with INDIRECT that work with closed workbooks without using macros? Like a "paste value" or something which you can use in the same way as INDIRECT but that returns a digit, without the formula notation in the cell?
EDIT:
=INDIRECT(CONCATENATE("'C:\path\[";O282;"]";$O$283;"'!D11"))
works for getting the value "D11" from the workbook O282. When I drag this formula out, the next column will reference to workbook P282. However, it still get cell D11. I want it to get the E11 cell from this workbook, and work like this. Does anyone have any idea?
=INDIRECT(CONCATENATE("'C:\";[#Path];"\[";[#WorkbookName];"]";[#SheetName];"'!";ADDRESS(11;COLUMN() - 11)))
I think up code is something that can you want.
Showing #### is sometimes because of cell width.