Forum Discussion
Excel
Jul 19, 2022Iron Contributor
Query related to VBA code
Hello Everyone, How to copy data from Master Data to Individual each sheet.. For example - I want to make sheets for each individual division.. Please help... Here is a attached fi...
JKPieterse
Jul 19, 2022Silver Contributor
Excel Convert your data to a table and insert a slicer on the Division column, no extra worksheets needed.
- ExcelJul 19, 2022Iron ContributorCan we do with the help of VBA code ?
- HansVogelaarJul 19, 2022MVP
Sub SplitData() Dim d As Object Dim ws As Worksheet Dim r As Long Dim m As Long Dim v As Variant Dim wt As Worksheet Application.ScreenUpdating = False Set d = CreateObject(Class:="Scripting.Dictionary") Set ws = Worksheets("Main Sheet") m = ws.Range("A" & ws.Rows.Count).End(xlUp).Row For r = 2 To m d(ws.Range("A" & r).Value) = 1 Next r For Each v In d.Keys Set wt = Nothing On Error Resume Next Set wt = Worksheets(v) On Error GoTo 0 If wt Is Nothing Then Set wt = Worksheets.Add(After:=Worksheets(Worksheets.Count)) wt.Name = v Else wt.UsedRange.Clear End If ws.UsedRange.AutoFilter Field:=1, Criteria1:=v ws.UsedRange.Copy Destination:=wt.Range("A1") wt.UsedRange.EntireColumn.AutoFit Next v ws.UsedRange.AutoFilter Application.ScreenUpdating = True End Sub- ExcelJul 19, 2022Iron ContributorSir Can you please explain this code? Please.