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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,536
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,136,954
Messages
5,678,759
Members
419,782
Latest member
gc75150

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