VBA: Split a table into multiple tables across different worksheets?

George201

New Member
Joined
Mar 20, 2024
Messages
1
Platform
  1. Windows
Hi, I'm fairly new to VBA and am trying to create some code to search through two columns in a table for specific criteria, create a new worksheet and extract these rows from the old table to a new one on the new worksheet.


For example using the table below. I'd like to look for rows containing Government, and then create a new worksheet for each country copying the rows over for that country. In the table I am using, countries are mentioned by two letter country code and full name.
SegmentCountryProductDiscount BandUnits SoldManufacturing PriceSale PriceGross Sales
GovernmentCanadaCarreteraNone
1618.5​
$ 3.00$ 20.00$ 32,370.00
GovernmentGermanyCarreteraNone
1321​
$ 3.00$ 20.00$ 26,420.00
MidmarketFranceCarreteraNone
2178​
$ 3.00$ 15.00$ 32,670.00
MidmarketGermanyCarreteraNone
888​
$ 3.00$ 15.00$ 13,320.00
MidmarketMexicoCarreteraNone
2470​
$ 3.00$ 15.00$ 37,050.00
GovernmentGermanyCarreteraNone
1513​
$ 3.00$ 350.00$ 529,550.00
MidmarketGermanyMontanaNone
921​
$ 5.00$ 15.00$ 13,815.00
Channel PartnersCanadaMontanaNone
2518​
$ 5.00$ 12.00$ 30,216.00
GovernmentFranceMontanaNone
1899​
$ 5.00$ 20.00$ 37,980.00
Channel PartnersGermanyMontanaNone
1545​
$ 5.00$ 12.00$ 18,540.00
MidmarketMexicoMontanaNone
2470​
$ 5.00$ 15.00$ 37,050.00
EnterpriseCanadaMontanaNone
2665.5​
$ 5.00$ 125.00$ 333,187.50
Small BusinessMexicoMontanaNone
958​
$ 5.00$ 300.00$ 287,400.00
GovernmentGermanyMontanaNone
2146​
$ 5.00$ 7.00$ 15,022.00

Again I am very new to VBA so any guidance or help is appreciated! Thanks :)
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
have you tried recording a macro of you adding a filter, setting the filter to show just goverment then copying all visible cells into a new sheet?
You could then review the code you created and adjust the to suit your needs.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top