Hi,
I am attempting to modify a macro I have that currently takes a look at a Master sheet, and based on the values it comes across in Col B, it will create new sheets based on those value names.
For example, Col B contains values such as:
b
c
d
e
f
g
So new sheets will be created based on the (filtered) criteria above and will be named accordingly as either, b, c, d, e, etc..
However, I am attempting to take this one step further, and have it create new sheets based on multiple column values.
For example, it should not only take a look at the values in Col B, but also at the values in Col G which contain conditions such as:
true
false
Here is the macro I am using that creates new sheets (from a master sheet) based on Col B values only:
Sub Macro2()
Dim rCell As Range, ws As Worksheet
Application.DisplayAlerts = False
With Sheets("Master")
Sheets.Add().Name = "Temp"
.Range("B1", .Range("B" & Rows.Count).End(xlUp)).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheets("Temp").Range("B1"), Unique:=True
For Each rCell In Sheets("Temp").Range("B2", Sheets("Temp").Range("B" & Rows.Count).End(xlUp))
.Range("B1").AutoFilter Field:=2, Criteria1:=rCell
Set ws = Worksheets.Add(After:=Worksheets(Worksheets.Count))
ws.Name = rCell
.AutoFilter.Range.Copy ws.Range("A2")
Next rCell
Sheets("Temp").Delete
.AutoFilterMode = False
End With
Application.DisplayAlerts = True
End Sub
My dilemma is that Im not sure how to get this to work with multiple columns (B and G) and create new sheet names accordingly with the filtered values?
By the way, a thought occurred that if it creates new sheets, it should ideally be named with respect to the combination of the two column values, such as:
bfalse
btrue
cfalse
ctrue
dfalse
dtrue
etc.
Thanks in advance for any help!
Bookmarks