Get value by referencing a cell

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,213
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
In E2 of Worksheet “Sheet2” I am using a formula =’7’!H120 which gives me value of cell H120 of the Worksheet with tab named ‘7” as a result in cell E2.

This formula in E2 is variable…it can be =’7’!B100; or =’7’!C555 or any formula like this.
I require an Excel formula in cell E3 of Worksheet “Sheet2” which should give me value of the cell which is $G$2 row below or above (IF G2=1, then 1 row below, IF $G$2=-1, then 1 row above) of the cell address which is being used in cell E2.
G2= an integer value

How to accomplish?
Thanks in advance.



Cross posted in Get value by referencing a cell
Referencing.xlsx
EFG
2221
3999
Sheet2
Cell Formulas
RangeFormula
E2E2='7'!H120
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Use this function instead of the one in that other thread.

VBA Code:
Function FormulaPt(r As Range, lPart As Long, RowOffset As Long) As String
  Dim s As String
  
  s = r.Formula
  Select Case lPart
    Case 1: FormulaPt = Mid(s, 3, 1)
    Case 2: FormulaPt = Mid(s, 6, 1)
    Case 3: FormulaPt = Right(s, 3) + RowOffset
  End Select
End Function

hsandeep.xlsm
EFGHIJKLMN
1-2
21217H118
3115
Sheet2
Cell Formulas
RangeFormula
L2:N2L2=FormulaPt($E2,COLUMNS($L:L),$G1)
E2E2='7'!H120
E3E3=myOffset(E2,G1)



.. or keep using that previous function and just adjust for the row offset when retrieving the third formula part

hsandeep.xlsm
EFGHIJKPQR
1-2
21217H118
3115
Sheet2
Cell Formulas
RangeFormula
P2P2=FormulaPart(E2,1)
Q2Q2=FormulaPart(E2,2)
R2R2=FormulaPart(E2,3)+G1
E2E2='7'!H120
E3E3=myOffset(E2,G1)
 
Upvote 1
Hi,
Not sure to fully understand ...
May be the first step is
Excel Formula:
=SUBSTITUTE(FORMULATEXT(E2),"='7'!","")
 
Upvote 0
@James006
OP's profile says Excel 2010 so they would not have access to the FORMULATEXT function.
 
Upvote 0
This is solved using vba provided by Peter SS
As a matter of interest, where did I do that?

In the other forum you wrote:
the Excel formula required should be able to read the formula of cell E2 ...
If you are using Excel 2010 as your profile says, a normal worksheet formula cannot read the formula in another cell. Such a function only became available in Excel 2013.
 
Last edited:
Upvote 0
With Excel 2010, you should create a Named Range, say, reference and define it with Refers To : =GET.CELL(6,Sheet2!$E$2)

Then wherever you need your result, you can use
Excel Formula:
=INDIRECT("'7'!"&SUBSTITUTE(SUBSTITUTE(reference,0,1),"='7'!",""))
 
Upvote 0
With Excel 2010, you should create a Named Range, say, reference and define it with Refers To : =GET.CELL(6,Sheet2!$E$2)
Don't know if it will be an issue for the OP, but that method is like a pseudo-macro and the workbook will need to be saved as a macro-enabled workbook.
 
Upvote 0
Don't know if it will be an issue for the OP, but that method is like a pseudo-macro and the workbook will need to be saved as a macro-enabled workbook.
Unless OP saves his workbook using: Excel 97 - 2003 Workbook (*.xls)
 
Upvote 0

Forum statistics

Threads
1,215,268
Messages
6,123,970
Members
449,137
Latest member
yeti1016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top