Hello,
I have an excel workbook 2010, in which i have a number of sheets.
In each sheet, I have the results of a particular test run and the analysis.
Now, for the analysis, I need to do a diff of the number of test-cases passed in the current run (Current Sheet) and the number of test-cases passed in the previous run (previous sheet).
And this formula I need for all the sheets.
Thus, how do I have a formula in which I do a diff of a value of the current sheet and the previous sheet.
I case of just two sheets (sheet1 and sheet2), if I have to do a diff on sheet2 then the formula is :
=B4-'sheet1'!B4
But this is when my sheet names are constant, but I need the formula such that for each new sheet, the formula picks the value from the previous sheet only.
Could someone please help me with this?
Also, I do not know how to create macros in excel, so if you provide the code for a new macro, I would be grateful if you could explain how to use/apply it also.
Thanks and regards,
Sunny
I think this is what you are after - I have attached a sample workbook with values in B4 and I am placing the formula of (current sheet b4 - previous sheet B4) into cell C5 - I have made the sheets not just Sheet 1, Sheet 2 etc - so this should work no matter what the worksheet is called. You could run this macro when you need to add the formulas to the sheets. To get to the code open the workbook and hit ALT F11 and this will take you to the VB Editor. The code is inside Module 1 - double click on Module 1 to see the code. Close the VB Editor once you have had a look at the code in the module. When you are back to the workbook to run the macro you need to select macros from the Developer tab in the workbook or hit ALT F8 and this will bring up a list of available macros to run - select macro called addFormula to run the macro.
Let me know if it does what you are after or need further help.
Here is a link to more information about macros http://office.microsoft.com/en-us/ex...010014113.aspx
Hope this helps.Sub addFormula() Dim ws As Worksheet, wsPr As String, x As Long For Each ws In ActiveWorkbook.Worksheets If x > 0 Then ws.Range("C5").Formula = "=B4-" & wsPr & "!B4" End If x = x + 1 wsPr = ws.Name Next End Sub
Anthony
“Confidence never comes from having all the answers; it comes from being open to all the questions.”
PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”
Last edited by smuzoen; 02-03-2012 at 06:38 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks