Hi Alfaman and Maddox,
Some minor changes have been done to make things independent from your sheets.
The Excel sheet that displays MF Data is now named "MFSheet".
All input data are moved in two subroutines
1. DefineGlobalParams()
2. DefineCellNames()
everything you might want to change in Excel is in the above subroutines
In MF the custom cell now is:
MFSheet!C1
and in Excel you see it on cell C1
All MF Data are displayed in MFSheet from row 2, as:
shiftrowdown = 1
row1 = shiftrowdown + 1
In Excel code exist in:
1. module1 (sub DefineGlobalParams(), sub DefineCellNames(), Funct ImportFromMFP())
2. ThisWorkbook Excel object (Workbook_SheetCalculate, Workbook_BeforeSave)
if you want to move code in another Workbook.
the solution is described below:
MF Data are output in rows according to market_index.
What I have done is to create (one cell) named ranges that redefine automatically their addresses every time, on the new row that displays MF Data.
So as an example let's suppose that the ImportFromMFP() custom formula in MF outputs the following parameters in Excel:
=ImportFromMFP(market_index, market_id, "market_name", s_1_sel_id, "s_1_sel_name", s_1_back_price, s_1_lay_price, s_2_sel_id, "s_2_sel_name", s_2_back_price, s_2_lay_price, s_3_sel_id, "s_3_sel_name", s_3_back_price, s_3_lay_price)
In Excel I defined the following cell names in public sub DefineCellNames
xl_market_name
xl_s_1_sel_name
xl_s_1_back_price
xl_s_1_lay_price
xl_s_2_sel_name
xl_s_2_back_price
xl_s_2_lay_price
xl_s_3_sel_name
xl_s_3_back_price
xl_s_3_lay_price
You can see them on top left in the Excel Name Box and MFPCell name as well
These excel cell names redefine automatically their address each time a new row is displayed.
So in a second sheet i.e. Sheet1 putting the formula "=xl_s_1_sel_name" on cell A3, it will always display s_1_sel_name of the current market.
The same for formula "=xl_s_2_sel_name" on cell A6, it will always display s_2_sel_name and for formula "=xl_s_3_sel_name" on cell A9, it will always display s_3_sel_name of the current market
Your trigger in MF will always read cell_Sheet1_A(sel_index*3+1) as before.
Even if MF Data display on different rows, on Sheet 1 we refer by named range names
The only thing you have to do is to add your named range cell names in public sub DefineCellNames
These cell names are stored on the array NRngCellNames()
NRngCellNames(i, 1) stores the cell name and
NRngCellNames(i, 2) stores the column position. The row address is always the row1 that displays MF Data
Just uncomment the commented lines to add.
If you have more than the 20 cell names (in comment), continue with:
NRngCellNames(21, 1) = "xl_yourcellname": NRngCellNames(21, 2) = 32 'column position
You can add 200 cell names.
Save and Workbook_BeforeSave event will create your additional cell names
You cal also use excel name manager to delete my cell names (with xl_ prefix) and define your own with your own notation. Pay attention only to "MFPCell" do not delete it.
Sheet1 has all you need to define your own template to be read from MF. I followed the format of the querymarket sheet that has been made for the job.
PS.
If you omit in Public Function ImportFromMFP the line:
row1 = market_index + shiftrowdown
only the current market will be displayed in row1=2, and the template sheets will continue to do the job.
OnError please on the forum.
Best Regards,
Theodore