Using cell reference in formula

jas1980

New Member
Joined
Oct 14, 2016
Messages
39
Office Version
  1. 2019
Platform
  1. Windows
I am tying to use a cell reference in 2 formulas.

The first is a hyperlink:
=HYPERLINK("C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\&$G$2&\MQL4\Files\BSA_ScreenShots\&$D24&_&$K24&_&$M24&.PNG","ClosePic")
I cannot get this to work, but when I first tried it worked and I cannot see what is different.
This is the same link (that works) manually added and without the cell references:
C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\C142B020C05FAD9EEC4BE1375F709241\MQL4\Files\BSA_ScreenShots\75496008_2021.02.14_20.43.47.PNG

This is the second that I have added cell references to:
TRIM(MID(SUBSTITUTE(,";",REPT(" ",LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\&$G$2\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A1))),(1-1)*LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\&$G$2\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A1)+1,LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\&$G$2\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A1)))

This is the formula that works without cell references:
=TRIM(MID(SUBSTITUTE('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\C142B020C05FAD9EEC4BE1375F709241\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2,";",REPT(" ",LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\C142B020C05FAD9EEC4BE1375F709241\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2))),(1-1)*LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\C142B020C05FAD9EEC4BE1375F709241\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2)+1,LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\C142B020C05FAD9EEC4BE1375F709241\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2)))

Hopefully someone can see where I'm going wrong with these?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
You have missing quotes. The cell references need to be outside the string parts so excel knows you mean the cell and are not being literal. eg this part:

"C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\&$G$2&\MQL4\Files\BSA_ScreenShots\&$D24&_&$K24&_&$M24&.PNG"

should be

"C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\"&$G$2&"\MQL4\Files\BSA_ScreenShots\"&$D24&"_"&$K24&"_"&$M24&".PNG"
 
Upvote 0
You have missing quotes. The cell references need to be outside the string parts so excel knows you mean the cell and are not being literal. eg this part:

"C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\&$G$2&\MQL4\Files\BSA_ScreenShots\&$D24&_&$K24&_&$M24&.PNG"

should be

"C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\"&$G$2&"\MQL4\Files\BSA_ScreenShots\"&$D24&"_"&$K24&"_"&$M24&".PNG"
Thank you for this, I will add to the sheet now :)
 
Upvote 0
The hyperlink formulas wok properly, but the trim still doesn't, I get a REF error when I add the cell reference to the formula like this:

=TRIM(MID(SUBSTITUTE('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\"&$G$2&"\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2,";",REPT(" ",LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\"&$G$2&"\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2))),(1-1)*LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\"&$G$2&"\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2)+1,LEN('C:\Users\jamie\AppData\Roaming\MetaQuotes\Terminal\"&$G$2&"\MQL4\Files\BSA_Transactions\[BSA_Transactions.csv]BSA_Transactions'!$A2)))

Is there a fix to stop this error?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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