Good morning / evening everyone!
I hope everyone is well. I was wondering if I could pick the brains trust here.
I have a workbook with two worksheets.
I have to filter the list on Worksheet A and copy paste the values into Worksheet B and then save copy as the name in Cell A2.
At the moment, I have managed to do get it to autofilter and create a new individual worksheets with the data.
At the moment, I am now copying the unique lists in those "new" worksheets into Worksheet B and then deleting all the other worksheets and doing a save as.
I am sure there has to be a shortcut way of auto-filtering Worksheet A and copying and pasting directly into Worksheet B, doing a save file as using the text in cell A2 and then clearing Worksheet B and looping again.
Can anyone help? Much thanks!
I hope everyone is well. I was wondering if I could pick the brains trust here.
I have a workbook with two worksheets.
I have to filter the list on Worksheet A and copy paste the values into Worksheet B and then save copy as the name in Cell A2.
At the moment, I have managed to do get it to autofilter and create a new individual worksheets with the data.
VBA Code:
Sub filter()
Application.ScreenUpdating = False
Dim x As Range
Dim rng As Range
Dim last As Long
Dim sht As String
sht = "Input"
last = Sheets(sht).Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Sheets(sht).Range("A1:J" & last)
Sheets(sht).Range("A1:A" & last).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("N1"), Unique:=True
For Each x In Range([N2], Cells(Rows.Count, "N").End(xlUp))
With rng
.AutoFilter
.AutoFilter Field:=1, Criteria1:=x.Value
.SpecialCells(xlCellTypeVisible).Copy
Sheets.Add(After:=Sheets(Sheets.Count)).Name = x.Value
ActiveSheet.Paste
End With
Next x
' Turn off filter
Sheets(sht).AutoFilterMode = False
With Application
.CutCopyMode = False
.ScreenUpdating = True
End With
End Sub
At the moment, I am now copying the unique lists in those "new" worksheets into Worksheet B and then deleting all the other worksheets and doing a save as.
I am sure there has to be a shortcut way of auto-filtering Worksheet A and copying and pasting directly into Worksheet B, doing a save file as using the text in cell A2 and then clearing Worksheet B and looping again.
Can anyone help? Much thanks!