VBAProIWish
Well-known Member
- Joined
- Jul 6, 2009
- Messages
- 1,027
- Office Version
- 365
- Platform
- Windows
Hello All,
I have a workbook that I download that contains a worksheet that has a varying amount of rows each time I download it.
Sometimes I can have 10 rows, while other times, I can have 80 rows. This worksheet has a column named "Fruit" and the number and kind of fruits can vary. There is also no master list of these fruits. New fruits can be added at any time, so a lookup list would not work in this scenario.
What I need is code that will create a new worksheet for each unique fruit in the fruits column, deleting all fruits except for that one unique fruit.
Note that there are usually no more than 20 unique fruits every time I download the workbook but this can vary.
Here's an example...
1. I download my usual workbook.
2. This particular time, there happens to be 6 unique fruits.
3. There are 21 rows in this download (Title row + 20 rows of data).
4 fruits each have values in 3 rows (12 rows total)
2 fruits each have values in 4 rows ( 8 rows total)
This is a total of 6 unique fruits. Therefore, in addition to the original worksheet, 6 additional worksheets should be created.
For example, let's say I have...
1. Banana - In 3 rows in the "Fruit" column
2. Grape - In 3 rows in the "Fruit" column
3. Cherry - In 3 rows in the "Fruit" column
4. Apple - In 3 rows in the "Fruit" column
5. Pineapple - In 4 rows in the "Fruit" column
6. Coconut - In 4 rows in the "Fruit" column
While keeping the original worksheet, 6 new distinct worksheets would be created (using each fruit as the worksheet name) with only those fruits, deleting all other rows with non-matching fruit (except the title row)
1. A "Banana" worksheet with 3 rows (+ Title row)
2. A "Grape" worksheet with 3 rows (+ Title row)
3. A "Cherry" worksheet with 3 rows (+ Title row)
4. A "Coconut" worksheet with 3 rows (+ Title row)
5. A "Pineapple" worksheet with 4 rows (+ Title row)
6. A "Coconut" worksheet with 4 rows (+ Title row)
I hope I explained this well enough. Please ask if there are any questions at all.
Thanks much to anyone who can help me with this!
I have a workbook that I download that contains a worksheet that has a varying amount of rows each time I download it.
Sometimes I can have 10 rows, while other times, I can have 80 rows. This worksheet has a column named "Fruit" and the number and kind of fruits can vary. There is also no master list of these fruits. New fruits can be added at any time, so a lookup list would not work in this scenario.
What I need is code that will create a new worksheet for each unique fruit in the fruits column, deleting all fruits except for that one unique fruit.
Note that there are usually no more than 20 unique fruits every time I download the workbook but this can vary.
Here's an example...
1. I download my usual workbook.
2. This particular time, there happens to be 6 unique fruits.
3. There are 21 rows in this download (Title row + 20 rows of data).
4 fruits each have values in 3 rows (12 rows total)
2 fruits each have values in 4 rows ( 8 rows total)
This is a total of 6 unique fruits. Therefore, in addition to the original worksheet, 6 additional worksheets should be created.
For example, let's say I have...
1. Banana - In 3 rows in the "Fruit" column
2. Grape - In 3 rows in the "Fruit" column
3. Cherry - In 3 rows in the "Fruit" column
4. Apple - In 3 rows in the "Fruit" column
5. Pineapple - In 4 rows in the "Fruit" column
6. Coconut - In 4 rows in the "Fruit" column
While keeping the original worksheet, 6 new distinct worksheets would be created (using each fruit as the worksheet name) with only those fruits, deleting all other rows with non-matching fruit (except the title row)
1. A "Banana" worksheet with 3 rows (+ Title row)
2. A "Grape" worksheet with 3 rows (+ Title row)
3. A "Cherry" worksheet with 3 rows (+ Title row)
4. A "Coconut" worksheet with 3 rows (+ Title row)
5. A "Pineapple" worksheet with 4 rows (+ Title row)
6. A "Coconut" worksheet with 4 rows (+ Title row)
I hope I explained this well enough. Please ask if there are any questions at all.
Thanks much to anyone who can help me with this!