Forum Discussion
Creating new Excel files based on values of a column
To achieve this, you can use Microsoft Excel's built-in features along with VBA (Visual Basic for Applications) scripting. Here is a step-by-step guide on how to create new Excel files for each community, filter the data, and send them to Google Drive. Note that the process involves multiple steps, and you may need to have some VBA coding skills.
Step 1: Copy and Filter Data
- In your original Excel file, create a new worksheet for each community (e.g., "A Club," "B Club," etc.).
- Filter the data for each community using Excel's AutoFilter or Filter function. You can do this by clicking on the filter icon in the "Community" column and selecting the community you want to filter.
- Copy the filtered data and paste it into the corresponding community worksheet.
- To convert each worksheet to a table (Excel Table), select the data, go to the "Insert" tab, and click on "Table."
Step 2: VBA Script to Create Individual Files
Now, you can use a VBA script to automate the process of creating individual Excel files for each community. Here is a simplified example:
Sub CreateCommunityFiles()
Dim ws As Worksheet
Dim community As Range
Dim newWorkbook As Workbook
' Loop through each community worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Overview" Then ' Skip non-community sheets
' Set the range of unique community values
Set community = ws.Range("D2:D" & ws.Cells(Rows.Count, "D").End(xlUp).Row)
' Loop through each unique community
For Each cell In community
' Create a new workbook
Set newWorkbook = Workbooks.Add
' Copy headers from the original worksheet
ws.Rows(1).Copy Destination:=newWorkbook.Sheets(1).Rows(1)
' Filter and copy data for the current community
ws.UsedRange.AutoFilter Field:=4, Criteria1:=cell.Value
ws.UsedRange.SpecialCells(xlCellTypeVisible).Copy Destination:=newWorkbook.Sheets(1).Cells(2, 1)
' Remove filter in the original worksheet
ws.AutoFilterMode = False
' Save the new workbook with the community name
newWorkbook.SaveAs "Path\to\save" & "\" & cell.Value & ".xlsx"
newWorkbook.Close SaveChanges:=False
Next cell
End If
Next ws
End Sub
Please note that you will need to adapt the script to your specific file structure, and you may need to make changes based on your data and folder paths.
Step 3: Share Files on Google Drive
Once you have created individual Excel files, you can share them on Google Drive:
- Upload the Excel files to your Google Drive.
- Right-click on each file and select "Share."
- Set the sharing options to allow only the manager of each community to download the file. You can do this by entering the manager's email address in the sharing settings.
By following these steps, you should be able to automatically create individual Excel files for each community, filter the data, and share them on Google Drive with the specified access permissions. The text, steps and the vba code were edited with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.