Use a cell value as part of a formula

barberic5

New Member
Joined
Nov 23, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I am trying to create a formula that uses the value of another cell as an argument in my formula.

This is my current formula:
=IFS([@Item]="","",$B$1="x",Sheet2!$B$2,TRUE,HYPERLINK(SUBSTITUTE(TRIM(SUBSTITUTE("Log In — Leaf Trade"&[@Item],"&","%26"))," ","+"),"Search LeafTrade"))

This is the value in Sheet2!$B$2:
HYPERLINK(SUBSTITUTE(TRIM(SUBSTITUTE("High Mountain Imports"&[@Item],"&","%26"))," ","+"),"Search High Mountain")

My formula won't actually calculate based on the value in Sheet2!$B$2, it just display exactly what i typed in Sheet2!$B$2
Cell Formulas
RangeFormula
H3:H10H3=IFS([@Item]="","",$B$1="x",Sheet2!$B$2,TRUE,HYPERLINK(SUBSTITUTE(TRIM(SUBSTITUTE("https://app.leaf.trade/shop/high-mountain-imports/search.php?search_query="&[@Item],"&","%26"))," ","+"),"Search LeafTrade"))


Zen Leaf Inventory Shopping List 2.xlsx
B
2HYPERLINK(SUBSTITUTE(TRIM(SUBSTITUTE("https://highmountainimports.com/search.php?search_query="&[@Item],"&","%26"))," ","+"),"Search High Mountain")
Sheet2
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
try replacing
Excel Formula:
Sheet2!$B$2
with
Excel Formula:
indirect(Sheet2!$B$2)
or
Excel Formula:
indirect(text(Sheet2!$B$2))
 
Upvote 0
Neither of those worked. It returns a #REF! error for the first one. The TEXT formula was incomplete for the second one, it didn't include the format portion of the formula
 
Upvote 0
Still returns an #REF! error.

Excel is so odd, sometimes the simplest tasks are the hardest thing to accomplish.
 
Upvote 0
How about
Excel Formula:
indirect("Sheet2!$B$2")
 
Upvote 0
That didn't work either. I get no errors, but it returns the same value as in my original post.
 
Upvote 0
The you need to clearly explain what you are trying to do, your formula is currently saying that if B1="x" return the value of B2 on sheet2
 
Upvote 0
The you need to clearly explain what you are trying to do, your formula is currently saying that if B1="x" return the value of B2 on sheet2
Yes, that is exactly what I am trying to do. However, B2 on Sheet2!$B$2 is a formula. So for Sheet1 Column H, I need it to actually calculate the formula from Sheet2!$B$2, as long as Sheet1!$B$1="x".


Sheet 1:
On my table in Sheet1 I have multiple columns representing: Product, Vendor, URL Link, etc.
Sheet1 Column H is the URL Link (Column named "*Search")

Sheet 2:
Sheet2 will have a table which lists every unique vendor from my table on Sheet1. Each vendor on Sheet2 will have a custom formula designed to modify its URL so non-managers can have access to a different website which hides sensitive company info (like pricing, etc.). The formula for how to modify the original URL will be different for each vendor.

IF $B$1="x": Modify original URL
IF $B$1<>"x": Use original URL

What I am trying to accomplish is a dynamic formula for Sheet1 Column H. The table on Sheet2 with the vendor list will change frequently and be quite long. That would make it a difficult to manage a long IF Statement for Sheet1 Column H. So, the table on Sheet2 is designed to hold all the URL modification formulas. Sheet1 Column H will then use XLOOKUP to match the vendor from Sheet1 to its corresponding URL modification formula (currently XLOOKUP is not necessary while I test this out with a single value in Sheet2. I will finish populating Sheet2 with all the vendors and add XLOOKUP to my Sheet1 Column H formula once I can get this working properly.)
 
Upvote 0
IF $B$1="x": Modify original URL
But the formula you posted if not trying to modify anything, it's just returning the value of B2 from sheet2.
If you need to modify the url, then you will need to explain how it should be modified.
 
Upvote 0

Forum statistics

Threads
1,215,332
Messages
6,124,313
Members
449,153
Latest member
JazzSingerNL

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