Macro to move sheet to another workbook if sheet name is equal to specified cell value

mack321

New Member
Joined
Sep 15, 2015
Messages
39
This one is a little complex and I am in way over my head on this one, but have come too far to turn back now. What I have is...
On workbook "1" I have tabs named for the inspectors and their order numbers are in column A. Then in workbook "2" each tab contains order details and is named with the order number. I would like a macro that would move the worksheets with corresponding numbers to workbook "1" adjacent to the inspectors sheet that has the order #.
Can this even be accomplished?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi mack321,

Yes this can be done, but it would be so much easier if you could be a drop more explicit with your question. For instance the actual names of Workbooks 1 & 2. Do either of the workbooks contain other tabs other than "Inspectors" and "order number" in books 1 & 2 respectively. Is there a header row on the "Inspectors" tabs.

If you could show us graphically what we are dealing with, then the saying that "A Picture Is Worth a Thousand Words" really holds true in this instance.

Regards,

igold
 
Upvote 0
Hi mack321,

Yes this can be done, but it would be so much easier if you could be a drop more explicit with your question. For instance the actual names of Workbooks 1 & 2. Do either of the workbooks contain other tabs other than "Inspectors" and "order number" in books 1 & 2 respectively. Is there a header row on the "Inspectors" tabs.

If you could show us graphically what we are dealing with, then the saying that "A Picture Is Worth a Thousand Words" really holds true in this instance.

Regards,

igold

Workbook 1 named "Inspection Report" and Workbook 2 named "Inspector1". Inspection report does contain additional tabs while Inspector1 only contains tabs relevant to this macro. And, there is a header row on each Inspectors tab.

EXAMPLE OF INSPECTOR TAB (PO is the number to match to named tabs in Inspector1

PO #Pickup #MemberLoad #BuyerInspectorCommodityRoutingCarrierContactPhoneShip DateDel. DateVendorShipperPickup CityPickup StateComplete Y/N
136887136887 RadishesVendor 9/18/20159/18/2015HartvilleOhio
136887136887 Lett LeafVendor 9/18/20159/18/2015HartvilleOhio
136887136887 HerbsVendor 9/18/20159/18/2015HartvilleOhio
136794TO24080 PineappleVendor 9/18/20159/21/2015PhiladelphiaPennsylvania

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Ok, since the Inspection Report Workbook contains tabs other that just the Inspectors, I am assuming that at least some of the other tabs are named with their PO#s, but there could also be a "Totals" page in there as well. I need a way to tell Excel to distinguish an "Inspector Name" tab from say a "Totals" tab. If it was just Inspectors and PO#s that would work.

Otherwise I would need the names of the other tabs (not the PO#'s, since we are going to be adding to them), or I would need the names of the Inspectors. If there is someplace in the workbook the lists the Inspectors I could get it from there or if you want to list them on a worksheet for the purpose of this macro I could get it from there as well (you have to tell me where).

Additionally, just to be clear, from your sample above this Inspector tab has multiple PO#s, which PO# tab has priority to sit adjacent to this Inspector tab.

Am I understanding what you want and do you understand what I need to work the logic...

igold
 
Last edited:
Upvote 0
Ok, since the Inspection Report Workbook contains tabs other that just the Inspectors, I am assuming that at least some of the other tabs are named with their PO#s, but there could also be a "Totals" page in there as well. I need a way to tell Excel to distinguish an "Inspector Name" tab from say a "Totals" tab. If it was just Inspectors and PO#s that would work.

Otherwise I would need the names of the other tabs (not the PO#'s, since we are going to be adding to them), or I would need the names of the Inspectors. If there is someplace in the workbook the lists the Inspectors I could get it from there or if you want to list them on a worksheet for the purpose of this macro I could get it from there as well (you have to tell me where).

Additionally, just to be clear, from your sample above this Inspector tab has multiple PO#s, which PO# tab has priority to sit adjacent to this Inspector tab.

Am I understanding what you want and do you understand what I need to work the logic...

igold

The inspector names are the sheet names in the Inspection Report workbook. What I could do in that workbook is hide the additional tabs, could we then tell the macro to only consider "unhidden" tabs? The first column is where the PO is contained that can be matched to the Inspector1 workbook.
 
Upvote 0
You might want to PM me and I will give you my email address. I think we could square this away better via email than the forum.

I would like a macro that would move the worksheets with corresponding numbers to workbook "1" adjacent to the inspectors sheet that has the order #

The macro you want to do is going to add tabs to the Inspection Report Workbook as PO#s. That would mean you would have always go in and hide the new tabs before every run of the macro..
 
Upvote 0
You might want to PM me and I will give you my email address. I think we could square this away better via email than the forum.



The macro you want to do is going to add tabs to the Inspection Report Workbook as PO#s. That would mean you would have always go in and hide the new tabs before every run of the macro..

Yes, these reports are run fresh daily so it's not a big deal. I already have a 3 step macro that I can build that into.
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,583
Members
449,174
Latest member
chandan4057

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