Here is my macro (VBA) solution. The way it would work would be like this:
When you select the cell that you need the VLOOKUP() to be performed in, the code creates the formula based on where PROFIT is in column J in the other workbook. If you happen to already be "in" that cell, then you would need to click another cell on the
sheet and then click/select it again to refresh the formula.
There is a Const value that must contain the full path and filename to the ExternalFile.xls and the worksheet that the table is on with the ! ending that information. You must change that in the code to match your path, filename and sheetname since I've
shown the full path on my system here as an example.
The example also assumes the cell needing the formula is C6, which I just picked from thin air, change that also.
To put the code to a test in your workbook, open the workbook that needs the VLOOKUP() formula, select the sheet it needs to go onto. RIGHT-click on that sheet's name tab and choose [View Code] from the list that appears. Copy the code below and paste
it into that code module and make the needed edits to it. Close the VBA Editor using its red-x or by pressing [Alt]+[Q] to return to the worksheet.
Make certain that you save the workbook as a Macro Enabled workbook, type .xlsm.
Here is the code with the lines that need to be changed indicated in bold text.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'This Const value must have the FULL path to the ExternalFile.xlsx
'file in it along with the worksheet name just as if it were part
'of a formula on the worksheet
'I have shown it with my test setup path, you must change it
'to work with your system setup.
Const thePath = _ "'Q:\ExcelHelpGiven\for_RaulSousa[ExternalFile.xlsx]GeneralData'!"
Dim startRow As Long
Dim tempAddress As String
'assumes the formula needs to go into cell C6, change as needed
'the $ symbols must be part of the indicated cell address.
If Target.Address <> "$C$6" Then
Exit Sub
End If
'first we have to find where "PROFIT" is on the sheet
Application.ScreenUpdating = False ' prevent flickering
tempAddress = thePath & "$J:$J"
Target.Formula = "=MATCH(" & Chr$(34) & "PROFIT" & Chr$(34) & _
", " & tempAddress & ",0)"
startRow = Target.Value ' get returned value for further use
'now use that row number (where PROFIT was found in column J)
'to build a new formula for the Target cell
'
Target.Formula = "=VLOOKUP(" & Chr$(34) & "Main Services" & Chr$(34) & _
"," & thePath & "$J$" & startRow & ":$V$550,MONTH($D$1)+1,FALSE)"
'and that should do it for you.
End Sub