Copying macro

Closed
group123 Posts 4 Registration date Tuesday April 12, 2016 Status Member Last seen April 12, 2016 - Apr 12, 2016 at 05:50 PM
group123 Posts 4 Registration date Tuesday April 12, 2016 Status Member Last seen April 12, 2016 - Apr 12, 2016 at 06:45 PM
I want to write a macro where it groups my data by group # and copy the data of each group # into different sheets.
Afterward, rename each sheets to the grouped name instead of "sheet1" or "sheet2".
The range of the source data is unknown but I can but a dummy group # to indicate the end of the group.

Currently I manually grouped the data source and copy each group # into different sheet. Than rename each sheet.

Thanks
Sam

1 response

Blocked Profile
Apr 12, 2016 at 06:17 PM
OK, so do what you are doing, but record it (a macro)! Let us know if you have problems recording a macro!
0
group123 Posts 4 Registration date Tuesday April 12, 2016 Status Member Last seen April 12, 2016
Apr 12, 2016 at 06:23 PM
I want to create a macro where it can group and transfer the data to different sheet automatically. Below are sample source data. When macro is executed, I will have
grp# 123 in one tab and 358 on another tab.

grp # company name hire date
123 abb joe smith 1/1/2016
123 abb john stein 1/5/2016
358 asus jane quinn 2/5/2016
358 asus jack jones 4/1/2016
0
group123 Posts 4 Registration date Tuesday April 12, 2016 Status Member Last seen April 12, 2016 > group123 Posts 4 Registration date Tuesday April 12, 2016 Status Member Last seen April 12, 2016
Apr 12, 2016 at 06:26 PM
the size of the data source is different each day. I can have four group# on one day or 10 group # on future days.
0
Blocked Profile
Apr 12, 2016 at 06:29 PM
Post some code and we can iterate through a loop...post your code here
0
group123 Posts 4 Registration date Tuesday April 12, 2016 Status Member Last seen April 12, 2016 > Blocked Profile
Apr 12, 2016 at 06:45 PM
result of recording the macro.

Sub Macro6()
'
' Macro6 Macro
'

'
Cells.Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A2:A10") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:E10")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Rows("2:3").Select
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Sheets("Sheet10").Select
Sheets("Sheet10").Name = "abb"
Sheets("Sheet1").Select
Range("B11").Select
Application.CutCopyMode = False
Rows("4:6").Select
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Sheets("Sheet11").Select
Sheets("Sheet11").Name = "asus"
Range("E21").Select
Sheets("Sheet1").Select
Range("C14").Select
Application.CutCopyMode = False
End Sub
0