Saving Worksheets from List

CallSignPilot

New Member
Joined
Aug 4, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
How can I save worksheets based on values in two columns?

I have a "Formulas" worksheet (consisting of various Excel code I use to pull data needed from "Data").

I have a "Charges" worksheet (consisting of A:O, this is essentially individual account charges)

I have a "List" worksheet (A is account numbers, B consists of the company that account in the same row A belongs to)

I loop through A2:A in "List" to generate worksheets.

VBA Code:
Sub Accounts_Companies()
Dim LR As Long, i As Long
Application.ScreenUpdating = False
With Sheets("List")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LR
        Sheets("Formulas").Copy Before:=Sheets("Formulas")
        ActiveSheet.Name = .Range("A" & i).Value
    Next i
End With
Application.ScreenUpdating = True
End Sub

How can I save all worksheets into workbooks based on the company they belong too?

E.g., I would like all account worksheets that belong to Company 1 (listed on "List") saved to a workbook called Company 1 (I don't want Formulas or the Charges worksheet to be saved).

Related, before I save all these worksheets, how can I remove formulas in range A1:C on each worksheet (not Formula/Data worksheets) so that I don't need to waste so much space/RAM?

Finally, is there a way to create worksheets based accounts for one company in A of "List", save these worksheets to a new workbook based on the company name, and then delete the new sheets, before repeating this for the next grouping of accounts?

I fear that I have more accounts per company than Excel will permit worksheets (estimate around 500).

Many thanks.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Welcome to the Board!

I think it would be very beneficial for us to see what your original data looks like, along with your expected output.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,063
Members
449,090
Latest member
fragment

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