A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hello PianSa,
I'm Ibhadighi and I'd happily help you with your question. In this forum, we are Microsoft consumers just like yourself.
Yes, you can construct a reference to a cell in a sparkline graph using a formula in Excel. However, you cannot directly use the formula within the sparkline's Data Range input. Instead, you have to use the INDIRECT function to convert the text string you've constructed into a valid cell reference.
The INDIRECT function evaluates a text string as a cell reference. Here's an example based on your description:
=INDIRECT("'[Fin-purch.xlsm]Sheet1'! G" & D50)
In this formula, if D50 is 58, the INDIRECT function will evaluate the text string to be '[Fin-purch.xlsm]Sheet1'! G58 and return the value from that cell.
However, the INDIRECT function works with sparklines a bit differently since sparklines expect a range. You need to construct the entire range as a text and then use INDIRECT. Here's an example of how you could use it for a sparkline:
=SPARKLINE(INDIRECT("'[Fin-purch.xlsm]Sheet1'! G" & D50 & ":G" & D51))
In this example, D50 might contain the starting row number, and D51 the ending row number, for the data range for the sparkline on 'Sheet1'. The INDIRECT function will turn the string into a range reference that the SPARKLINE function can use.
Please note:
- INDIRECT can only reference open workbooks. If 'Fin-purch.xlsm' is not open, the function will return a reference error.
- INDIRECT is a volatile function and can slow down your workbook if used extensively.
- This syntax assumes you are using a version of Excel that supports dynamic arrays or you are entering it as an array formula.
I hope this helps.
Best Regards, Ibhadighi