gleamng
Board Regular
- Joined
- Oct 8, 2016
- Messages
- 98
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- 2003 or older
- Platform
- Windows
- MacOS
- Mobile
- Web
Good day everyone, the code below is a credited to @DanteAmor, though i made a little unprofessional editing on it to suit my need. However, i want this vba to also save all sheets as workbook excempting "Sheet1" after filtering to sheets.
thanking you all for your continued support.
thanking you all for your continued support.
VBA Code:
Option Explicit
Sub Filter()
Dim sht As Worksheet
Dim a As Variant, ky As Variant
Dim rng As Range
Dim dic As Object
Dim i As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set sht = Sheets("Sheet1") 'Specify sheet name where data is resident
Set dic = CreateObject("scripting.dictionary")
Set rng = sht.Range("A1:E" & sht.Cells(Rows.Count, "D").End(xlUp).Row)
a = rng.Value
For i = 2 To UBound(a, 1)
dic(a(i, 4)) = Empty
Next
For Each ky In dic.keys
On Error Resume Next: Sheets(ky).Delete: On Error GoTo 0
rng.AutoFilter
rng.AutoFilter field:=4, Criteria1:=ky
sht.AutoFilter.Range.Offset(2).Resize(, 5).Copy
Sheets.Add(after:=Sheets(Sheets.Count)).Name = ky
Range("A2").PasteSpecial (xlPasteAll)
Range("A:A,C:D").Delete
Range("A1").Value = ("VER NO.")
Range("B1").Value = UCase(ky)
Columns("A:B").EntireColumn.AutoFit
Range("A1").Select
Next
'Turn off filter
sht.Activate
sht.AutoFilterMode = False
With Application
.CutCopyMode = False
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub