Hello all,
Attached you'll see a representation of a real-life problem I'm trying to sort out via VBA.
In the 'Delivery Planning' sheet we have a list of US state codes that a fictional company operates in. The data in this sheet corresponds to the daily planned deliveries for each of these states.
In the 'Codes' sheet is a master list of all the states for which deliveries will need to be planned for the near future.
In the 'For Reference' sheet is a list of 50 state codes, which we don't really have to worry about.
I'm trying to write a macro that will update the list of state headings in 'Delivery Planning' to reflect the master list in 'Codes'. Sounds simple, right? I thought so too. Except that the code needs to account for more than just the headings. The delivery data in B4:AO132 will need to move around also so that the correct planned deliveries stay underneath the correct state. So, the code needs to insert columns too.
To add to this, it's not always the case that the update will simply need to add new states to the 'delivery planning' sheet, oh no! Sometimes states are removed from the master list and need to be removed from the planning sheet (deactivated states). The reverse is also true, in that sometimes states will be added to the master list and therefore need to be added to the planning sheet (newly activated states).
So, the 'Delivery Planning' headings need to reflect the 'Codes' table while preserving the data that's already in there. I guess I need code that inserts/deletes columns in the planning sheet as necessary, but that is aware of when columns need to be added or deleted specifically.
Thanks for your help!
Attached you'll see a representation of a real-life problem I'm trying to sort out via VBA.
In the 'Delivery Planning' sheet we have a list of US state codes that a fictional company operates in. The data in this sheet corresponds to the daily planned deliveries for each of these states.
In the 'Codes' sheet is a master list of all the states for which deliveries will need to be planned for the near future.
In the 'For Reference' sheet is a list of 50 state codes, which we don't really have to worry about.
I'm trying to write a macro that will update the list of state headings in 'Delivery Planning' to reflect the master list in 'Codes'. Sounds simple, right? I thought so too. Except that the code needs to account for more than just the headings. The delivery data in B4:AO132 will need to move around also so that the correct planned deliveries stay underneath the correct state. So, the code needs to insert columns too.
To add to this, it's not always the case that the update will simply need to add new states to the 'delivery planning' sheet, oh no! Sometimes states are removed from the master list and need to be removed from the planning sheet (deactivated states). The reverse is also true, in that sometimes states will be added to the master list and therefore need to be added to the planning sheet (newly activated states).
So, the 'Delivery Planning' headings need to reflect the 'Codes' table while preserving the data that's already in there. I guess I need code that inserts/deletes columns in the planning sheet as necessary, but that is aware of when columns need to be added or deleted specifically.
Thanks for your help!