Hi,
This is my first post here, so thank you for having me. I have been using these forums as a source for my issues since I started with VBA 3 months ago, and have written the majority of a program thanks to forums like these
I have a workbook with 5 sheets with approximately 30 columns per sheet. Each sheet uses identical column headers, but they differ in their range location by sheet.
I have a 6th sheet with individual user preferences stored in it. This sheet has a unique userID and then all of the 30 columns in the other 5 sheets with either a "1" or a blank value in it. The "1" indicates that this user has data for the column in the subsequent 5 sheets.
What I need to do, is for a particular user ("Smith123"), loop through his/her user preferences sheet and determine which columns have a "1" in them. The code then needs to loop through the subsequent 5 sheets and copy only those corresponding columns for the user into a new workbook. The user is a Public String that is entered in a user form when the individual opens the workbook. Let's call this variable a "UserID".
I cannot accomplish manually because there are too many users.
Sample:
Sheet1 - User Preferences
UserID Apples Oranges Kiwi Plums
Smith123 1 1 1
John 234 1 1
Sheet2 - Database Totals
UserID Apples Oranges Kiwi Plums
Smith123 75 23 54
John234 19 4
Sheet3 - Average Consumption
UserID Apples Oranges Kiwi Plums
Smith123 7.5 2.3 5.4
John234 1.9 .4
In this example, the code needs to know for UserID "Smith123" to loop through Sheet2,3,4 etc. and copy only the columns that have a "1" in them based on the Sheet1 preferences (so Apples, Organges, and Plums). The desired end-state is a new workbook with a sheet "Database Totals" and Smith123 values for Apples, Oranges, and Plums (as well as one for Average Consumption etc) and the flexability to use the variable "UserID" to run this macro for any user (e.g. do not hard code for Smith123).
I uploaded a sample workbook for your reference. The columns in the "User Preference" sheet are static and do not move, but the columns in the other sheets can move.
Any thoughts?
Bookmarks