In a hurry, so I've not the time to customize this, but I did something similar recently. Hopefully this will give you ideas on how to do what you're after. This WB creates a menu based on a list in the WB which can vary in size. Since you can't pass parameters via the OnAction property of a menu item, I had to write a bunch of tiny subroutines, each a numbered variant, to assign to the menu items. The conditional compiling statements are 'cause some users are on XL97 - strip 'em out if you can.
Anyway, I hope this yields some ideas...
<font face=Courier New>#<SPAN style="color:#00007F">Const</SPAN> booUseNewCode = VBA6</FONT>
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Open()
<SPAN style="color:#007F00">'...Other Code...</SPAN></FONT>
<font face=Courier New> <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> rngMenu.Cells.Count
MyAddControlToPopup AutoLoadMenu, newMenuItem, i, rngMenu.Cells(i).Value, _
"AutoLoad" & i
#<SPAN style="color:#00007F">If</SPAN> booUseNewCode <SPAN style="color:#00007F">Then</SPAN>
BuildAutoLoads i, vbc
#<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">Next</SPAN> i
<SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
<font face=Courier New>
<SPAN style="color:#007F00">'==============================================================================</SPAN>
<SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Sub</SPAN> BuildAutoLoads(<SPAN style="color:#00007F">ByVal</SPAN> x <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, vbc <SPAN style="color:#00007F">As</SPAN> VBComponent)
<SPAN style="color:#007F00">'------------------------------------------------------------------------------</SPAN>
<SPAN style="color:#007F00">' Would have preferred to put the code for this in the Workbooks Open method</SPAN>
<SPAN style="color:#007F00">' However, virus scanning software kept flagging this file as infected if</SPAN>
<SPAN style="color:#007F00">' the Open() method included an InsertLines method. However, just moving</SPAN>
<SPAN style="color:#007F00">' it here seems to fool the virus scanning software into letting it go.</SPAN>
<SPAN style="color:#007F00">' This procedure is called by the Open method and is designed to always</SPAN>
<SPAN style="color:#007F00">' ensure that there are corresponding "AutoLoadX()" subroutines for each</SPAN>
<SPAN style="color:#007F00">' menu option that would be created by adding items to the Customer List</SPAN>
<SPAN style="color:#007F00">' All of this nonsense could be avoided if one could set a menu's</SPAN>
<SPAN style="color:#007F00">' Action property in manner that permitted passing a parameter.</SPAN>
#<SPAN style="color:#00007F">If</SPAN> booUseNewCode <SPAN style="color:#00007F">Then</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> strCode <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
strCode = vbCrLf & "Sub AutoLoad" & Trim(Str(x)) & "()" & vbCrLf
strCode = strCode & vbTab & "AutoLoad " & x & vbCrLf
strCode = strCode & "End Sub"
vbc.CodeModule.InsertLines vbc.CodeModule.CountOfLines + 1, strCode
#<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
Example of Subroutine created by above code:
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> AutoLoad1()
AutoLoad 1
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">Sub</SPAN> AutoLoad2()
AutoLoad 2
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
Regards,