Below is code kindly provided by killazzz. Attached is the document that contains the code.
Within the document is a userform that contains a series of comboboxes, some of which are disabled. Each combobox represents an item that has a unique price.
When the code is executed, any comboboxes that are enabled, but false will be added to the document in the form:
checkbox.caption <TAB SPACE> £ <TAB SPACE> Price
VB Code:
Private Sub CommandButton1_Click()
'you define an array of all your prices and string variables
I am now attempting to alter the code slightly so that the items to be added to the document are done so using a table.
What I have attempted to do is create another array that has 3 columns and the number of rows is equal to the number of items to be added. I than want to create a table of equivalent dimensions and add that to the document.
For example, if there were 2 items to be added to the document (in reality the list is much larger), I would get a 2 row, 3 column table, which would contain the following items.
I also want to set column sizes and word alignment, but can probably work that out later. I have made numerous attempts at the above, but am having real difficulty. I have referenced arrays in the help files in vba, but can't seem to apply the information correctly (obviously it is the help files at fault )
Any help appreciated.
Last edited by New2vba; Mar 26th, 2006 at 12:30 PM.
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
Thanks again killazzz, but I am afraid this is not exactly what I meant.
I want to add my values to a table, which I will then insert at a bookmark. I have some code from DKenny (seems all the decent code I have was provided by one of the esteemed members of vbforums ) for creating a table on the fly, but am having trouble adapting it.
I was guesing that first an additional array would be needed to store the values for entry into the table, but maybe this isn't the case?
I know that each cell in column 2 will always contain "£" and the table will always have 3 columns.
To clarify, if say checkboxes 1, 3, and 5 are enabled and false, then the table would be 3 rows by 3 columns and would contain: