verticalstall
New Member
- Joined
- Jun 28, 2017
- Messages
- 4
Hey all!
So I'm definitely under water here...
I have a worksheet with 240 columns, each with a header. I have checkboxes on a userform that reference up to 54 of these columns. Users can select checkboxes based on what they would like to see in the final data set (typically 25-30 boxes will be checked). I need to either copy the relevant columns to a new worksheet (my current method) or delete all unselected columns (perhaps this would be faster/more efficient?). I then need to rearrange the columns to a pre-defined and constant order (currently using a LBound/UBound array function).
My current code extracts these columns to a new worksheet based on their static position within the original dataset using an IF…THEN statement evaluating each checkbox (which I'm sure is far from the most efficient method). However, I would like to create code that can find the relevant columns if they were to shift around (addition of new columns, etc.) in future datasets.
My thought is to use the checkboxes to pass the column header titles to an array. With the user-defined "relevant" columns, I could then use that array to search through the 240 columns for each header title in the array. Any unselected columns would be placed in a union for deletion at the conclusion of the search. The roadblock: I'm still really new at VBA and I'm having trouble translating the ideas (are they even correct?) into code. Any shoves in the right direction would be appreciated!
So I'm definitely under water here...
I have a worksheet with 240 columns, each with a header. I have checkboxes on a userform that reference up to 54 of these columns. Users can select checkboxes based on what they would like to see in the final data set (typically 25-30 boxes will be checked). I need to either copy the relevant columns to a new worksheet (my current method) or delete all unselected columns (perhaps this would be faster/more efficient?). I then need to rearrange the columns to a pre-defined and constant order (currently using a LBound/UBound array function).
My current code extracts these columns to a new worksheet based on their static position within the original dataset using an IF…THEN statement evaluating each checkbox (which I'm sure is far from the most efficient method). However, I would like to create code that can find the relevant columns if they were to shift around (addition of new columns, etc.) in future datasets.
My thought is to use the checkboxes to pass the column header titles to an array. With the user-defined "relevant" columns, I could then use that array to search through the 240 columns for each header title in the array. Any unselected columns would be placed in a union for deletion at the conclusion of the search. The roadblock: I'm still really new at VBA and I'm having trouble translating the ideas (are they even correct?) into code. Any shoves in the right direction would be appreciated!