How to split master data into multiple sheets using VBA

Published: 26 April 2020
on channel: Programming Notes
2,025
21

How to split the master spreadsheet into multiple sheets using VBA?
In this video, you will learn how to split data in excel into multiple sheets using VBA?

Sub Split_data()
Dim iRow As Integer
Dim Uniqe_Data As Integer
Dim Rng As Range

'for getting unique field data
Set Rng = Sheet1.Range("D2:D" & Sheet1.Cells(Rows.Count, "D").End(xlUp).Row)
Rng.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheet1.Range("M1"), Unique:=True
Uniqe_Data = Sheet1.Cells(Rows.Count, "M").End(xlUp).Row

For iRow = 2 To Uniqe_Data
'applying autofilter
Sheet1.Range("A1:G1").AutoFilter Field:=4, Criteria1:=Sheet1.Range("M" & iRow).Value
'sheet add
Sheets.Add After:=Sheets(Sheets.Count)
'Rename sheet name
Sheets(Sheets.Count).Name = Sheet1.Range("M" & iRow).Value
'Copy Data
Sheet1.Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy
'Paste data on new added sheet
Sheets(Sheets.Count).Range("A1").PasteSpecial (xlPasteValues)

Next iRow
Sheet1.AutoFilterMode = False
Application.CutCopyMode = False
MsgBox "Data has been separated.", vbInformation
End Sub

Website name
AVIT Guru

Website URL
http://www.avitguru.com/

Registration Form
http://www.avitguru.com/avit-guru-cou...

Course URL
Advanced Excel & MIS
http://www.avitguru.com/advanced-exce...

VBA MAcro Automation
http://www.avitguru.com/online-traini...

MS Access Database
http://www.avitguru.com/ms_access_dat...


On this page of the site you can watch the video online How to split master data into multiple sheets using VBA with a duration of hours minute second in good quality, which was uploaded by the user Programming Notes 26 April 2020, share the link with friends and acquaintances, this video has already been watched 2,025 times on youtube and it was liked by 21 viewers. Enjoy your viewing!