Copying macro

[Closed]
Report
Posts
4
Registration date
Tuesday April 12, 2016
Status
Member
Last seen
April 12, 2016
-
Posts
4
Registration date
Tuesday April 12, 2016
Status
Member
Last seen
April 12, 2016
-
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 reply


OK, so do what you are doing, but record it (a macro)! Let us know if you have problems recording a macro!
Posts
4
Registration date
Tuesday April 12, 2016
Status
Member
Last seen
April 12, 2016

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
Posts
4
Registration date
Tuesday April 12, 2016
Status
Member
Last seen
April 12, 2016
>
Posts
4
Registration date
Tuesday April 12, 2016
Status
Member
Last seen
April 12, 2016

the size of the data source is different each day. I can have four group# on one day or 10 group # on future days.
Blocked Profile
Post some code and we can iterate through a loop...post your code here
Posts
4
Registration date
Tuesday April 12, 2016
Status
Member
Last seen
April 12, 2016
> Blocked Profile
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