I have the following table in sheet1(Export):
-----------------------------
| col1 | col2 |..cN..|ctr_type|
-----------------------------
|value |value |valueN|CtrType1|
-----------------------------
|value |value |valueN|CtrType2|
-----------------------------
|value |value |valueN|CtrType3|
-----------------------------
|value |value |valueN|CtrType1|
-----------------------------
|value |value |valueN|CtrType3|
-----------------------------
|value |value |valueN|CtrType2|
-----------------------------
Where ctr_type is the name of the sheet in which the afferent values must be copied.
So my question is: how to copy values in their afferent sheets.
One expected output would be that all the value from the table which have CtrType1 in the column ctr_type would be copied in a existin sheet with the name CtrType1.
Thank you!
Could use something like the following. Assumes you data has headers and starts in column 1 and that there is no data to the right of the table. Otherwise, change the method for determining the last column.
I have helper functions to find the last row and column. I loop the last column to get the unique sheet names stored in a dictionary and at the same time add the range to the left of the sheet name into the dictionary. If the sheet name exists as a key in the dictionary, I use Union to add the current range to the left to the existing rows found for this sheet name.
I re-loop the dictionary using the sheet name keys to write the values to the appropriate sheets. You should add error handling e.g. what if sheet is not present?