I have Google Spreadsheet Document with a Master Sheet. Rows in this Master sheet will keep on increasing.

Each row in the Master Sheet has some numeric values (from column F to M) which need to be splitted into smaller lots using the corresponding values in columns P to W.

There is a custom menu (Split Row Value) which is supposed to function as below

Create a new sheet Nnamed "SPLIT-n", where n is a sequential number starting with 1. Copy the entire heading row from MASTER to SPLIT-n on row 1.
Copy the first chosen row (Column N) where SPLITTED Column (column X) is Blank
Paste the entire row from MASTER in Newely created SPLIT-n sheet on Row 2.
Split the values in Column F to M by dividing them corresponding value in Column P to W and paste the results below.
Repeat step 4 till there are no values left in column F to M.
Fill "SPLITTED" in Master Sheet on the same row which was splitted into smaller lots and apply the same formatting.
Copy the next chosen row from Master and paste on next available row in SPLIT-n
Repeat Step 4-7 till all chosen rows are splited.
I need the code for the UDF which will perform the above mentioned task. I have created the first SPLIT Sheet manually for reference.

Please help me with UDF Code. Thanks

Link below to my document with sample data.

https://docs.google.com/spreadsheets...4xP6dt/pubhtml