Generate sheets in new workbook instead of existing file

Siddhu11011

Board Regular
Joined
Jun 22, 2022
Messages
56
Office Version
  1. 365
Platform
  1. Windows
Macro1 creates multiple sheets and the same work book and Macro2 feeds the data in sheets created by Macro1

Macro1 depends on data in columns A to P of master_db sheet and new sheets creation is based on unique product name available in Column B of master_db sheet.

Macro2 looks into same unique product name which was created in Macro1. We have multiple sheets available which is created in macro1, now macro 2 pick one by one product name and fetch the data from "comparison" sheet. That sheet has data from column A to E.

Sub Macro1()
Dim x As Range
Dim Rng As Range
Dim last As Long
Dim sht As String

sht = "master_db"
last = Sheets(sht).Range("A1:P" & last)
Sheets(sht).Range("B1:B" & last). AdvancedFilter Action:=XlFilterCopy, CopyToRange:=Range("AA1"), Unique:=True

For Each x In Range([AA2], Cells(Rows.Count, "AA").End(xlUp))

Sheets.Add(After:=Sheets(Sheets.Count)).Name = x.Value

Next x
End Sub

Sub Macro2()
Dim rngCell As Range
Dim rngWork As Range
Dim wsPivot As Worksheet

Set wsPivot = ThisWorkbook.Worksheets("Pivot")
With wsPivot
Set rngWork = .Range("A1:E" & .Cell(.Rows. Count, "A").End(xlUp).Row)
If Not rngWork Is Nothing Then

For Each rngCell In .Range([AA2], .Cells(Rows.Count, "AA").End(xlUp))

With rngWork
.AutoFilter
.AutoFilter Feild:=1, Criterial:=rngCell.Value
.SpecialCells(xlCellTypeVisible).Copy Worksheets(rngCell.Value).Range("A")
End With

End Sub

Requirement:
I want macro to create new sheets in the new work book (instead of the same workbook) and pull the data from comparison sheet in the new workbook- in respective sheet
Is that a possible?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Macro1 creates multiple sheets and the same work book and Macro2 feeds the data in sheets created by Macro1

Macro1 depends on data in columns A to P of master_db sheet and new sheets creation is based on unique product name available in Column B of master_db sheet.

Macro2 looks into same unique product name which was created in Macro1. We have multiple sheets available which is created in macro1, now macro 2 pick one by one product name and fetch the data from "comparison" sheet. That sheet has data from column A to E.

Sub Macro1()
Dim x As Range
Dim Rng As Range
Dim last As Long
Dim sht As String

sht = "master_db"
last = Sheets(sht).Range("A1:P" & last)
Sheets(sht).Range("B1:B" & last). AdvancedFilter Action:=XlFilterCopy, CopyToRange:=Range("AA1"), Unique:=True

For Each x In Range([AA2], Cells(Rows.Count, "AA").End(xlUp))

Sheets.Add(After:=Sheets(Sheets.Count)).Name = x.Value

Next x
End Sub

Sub Macro2()
Dim rngCell As Range
Dim rngWork As Range
Dim wsPivot As Worksheet

Set wsPivot = ThisWorkbook.Worksheets("Pivot")
With wsPivot
Set rngWork = .Range("A1:E" & .Cell(.Rows. Count, "A").End(xlUp).Row)
If Not rngWork Is Nothing Then

For Each rngCell In .Range([AA2], .Cells(Rows.Count, "AA").End(xlUp))

With rngWork
.AutoFilter
.AutoFilter Feild:=1, Criterial:=rngCell.Value
.SpecialCells(xlCellTypeVisible).Copy Worksheets(rngCell.Value).Range("A")
End With

End Sub

Requirement:
I want macro to create new sheets in the new work book (instead of the same workbook) and pull the data from comparison sheet in the new workbook- in respective sheet
Is that a possible?
Hello there...
Is there any way to achieve above?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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