So I'm working on a project to keep track of all the supplies I need to keep on hand in Mr. Rogers Neighborhood to keep all of my animals alive. I have hundreds of different sheets and I'm trying to just be able to input all of my values on 1 sheet and send them to their respective sheets, with the sheet name in column A and the destination range which I can update depending on what row I want to send the data to. (All of the data will be pasted in the same row and column of each respective worksheet.) This is the code I'm using that works:
It wouldn't be too difficult to write the code for hundreds of sheets by just concatenating a couple of different columns in Excel but I'm trying to learn VBA so I've been attempting to figure out a loop to assign values to the array:![]()
Please Login or Register to view this content.
and then a loop for the copy, paste function:![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
What I picture this code doing during the first i loop is taking the value in "A2" which is "cat" and make that value = dept(2)
second loop takes the value of "B3" which is "dog" and making that value = dept(3)
and once I have all of those values assigned it moves on to the j loop which I'm thinking (for the first iteration) copies the values in the range B2:E2 in the supplies sheet and then pastes it in the worksheet animal(2) which has been assigned the value of "cat" in the previous loop into the range that I've specified in beg and fin.
Alas, Mr. Rogers keeps running into range issues and now all of his wonderful critters are at risk of slowly and painfully withering away unless you wonderful people can help him figure out how to make his code work. Thanks in advance for all of your help!
Bookmarks