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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,601
Office Version
  1. 365
Platform
  1. Windows
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"
 

jas1980

New Member
Joined
Oct 14, 2016
Messages
39
Office Version
  1. 2019
Platform
  1. Windows
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 :)
 

jas1980

New Member
Joined
Oct 14, 2016
Messages
39
Office Version
  1. 2019
Platform
  1. Windows
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?
 

Forum statistics

Threads
1,141,400
Messages
5,706,212
Members
421,432
Latest member
yash0468

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
Top