Hi guys and girls,
I'd be really grateful for help on this one... I don't dare guess how many hours (days?!) I've been trying to solve this.
Background
I have made a Budget workbook with four sheets: one for the household, one for me, one for my partner and a "Reference" sheet for calculations, information storage etc. I have designed a UserForm for inputting real income/spend data into the Budget.
My procedures to prepare and populate the UserForm for data entry do the following:
StartingCell: determines where on the relevant Sheet to extract the first value from, depending on the month. e.g. March happens to be "G4".
ExtractData: uses a For/Next loop to hop down that column (sometimes skipping cells not intended to hold data -different Offsets) and on each iteration adds the activecell.value to an array, arrExtracted.
DataToRef: pastes these values into the Reference sheet (which will keep track of changes made during UserForm manipulation)
RefToArray: copies values from the Reference sheet to another array.
ArrayToForm: copies from this array into the UserForm.
We all have a different number of expenditure categories (my partner has the fewest, of course!) and I'd appreciate help explaining if/how I can vary the size of the array (just 1-D) depending on the active sheet at the time the button to begin the sequence is pressed. A variable, x (Integer) is declared Public and is set to reflect the size of the array I need (e.g. 20) early on but I can't figure out how to vary the array itself accordingly.
The whole point was to avoid triplicating the UserForms, code etc. and now I'm plain curious to know if this can be done.
As an aside, is it possible to use another For/Next loop in ArrayToForm to feed values into the textboxes of the UserForm along these lines:
With frmEditBudget
Sorry for all the questions. And many thanks...
Alex
I'd be really grateful for help on this one... I don't dare guess how many hours (days?!) I've been trying to solve this.
Background
I have made a Budget workbook with four sheets: one for the household, one for me, one for my partner and a "Reference" sheet for calculations, information storage etc. I have designed a UserForm for inputting real income/spend data into the Budget.
My procedures to prepare and populate the UserForm for data entry do the following:
StartingCell: determines where on the relevant Sheet to extract the first value from, depending on the month. e.g. March happens to be "G4".
ExtractData: uses a For/Next loop to hop down that column (sometimes skipping cells not intended to hold data -different Offsets) and on each iteration adds the activecell.value to an array, arrExtracted.
DataToRef: pastes these values into the Reference sheet (which will keep track of changes made during UserForm manipulation)
RefToArray: copies values from the Reference sheet to another array.
ArrayToForm: copies from this array into the UserForm.
We all have a different number of expenditure categories (my partner has the fewest, of course!) and I'd appreciate help explaining if/how I can vary the size of the array (just 1-D) depending on the active sheet at the time the button to begin the sequence is pressed. A variable, x (Integer) is declared Public and is set to reflect the size of the array I need (e.g. 20) early on but I can't figure out how to vary the array itself accordingly.
The whole point was to avoid triplicating the UserForms, code etc. and now I'm plain curious to know if this can be done.
As an aside, is it possible to use another For/Next loop in ArrayToForm to feed values into the textboxes of the UserForm along these lines:
With frmEditBudget
For n = 1 to x
?.txtIn.value = arrExtracted
Next
Sorry for all the questions. And many thanks...
Alex