Okay. This chunk of my code:
Replaces this chunk of your code:
Instead of 10 variables, we use one array variable. Values 3 to 10 follow a regular pattern to increment the column numbers, so we don't need to write a separate line for each variable - we can loop through them. So, when i is 3, we set CellRef(3) to be S2LI.cells(RowNumba, 62). When i is 4, we set CellRef(4) to be S2LI.Cells(RowNumba,65). And so on. It's just a way of reducing / simplifying the code.
Now, as for looping through x from 1 to 10:
I have highlighted in red all instances of the x variable in this loop. We are essentially using the x variable to loop through all the (potential) source data, and using the i variable to format and write the output range.
I hope that helps clarify what the code is doing. Now, time for ME to ask you another question: does it achieve what you expected? And if not, what needs changed?
Bookmarks