Thread
:
vba code to filter the data like a group with group header
View Single Post
#
4
Posted to microsoft.public.excel.programming
Archana[_2_]
external usenet poster
Posts: 2
vba code to filter the data like a group with group header
On Friday, April 12, 2013 9:13:45 AM UTC-5, Claus Busch wrote:
Hi,
Am Fri, 12 Apr 2013 06:30:18 -0700 (PDT) schrieb
:
Item1 Item2 Sales
Group1 1 $10
Group1 2 $20
Group1 3 $20
Group2 1 $20
Group2 1 $30
Group3 1 $10
Group3 1 $15
try:
Sub Filter()
Dim LRow As Long
Dim i As Integer
Dim shName As String
Application.ScreenUpdating = False
With Sheets("Sheet1")
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = 1 To 3
shName = "Group" & i
.Range("A1:C" & LRow).AutoFilter _
field:=1, Criteria1:=shName
ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = shName
.Range("B1:C" & LRow).Copy _
Sheets(shName).Range("A1")
Next
.AutoFilterMode = False
End With
Application.ScreenUpdating = True
End Sub
Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
Claus,
Thank you very much! But I don't want to create the different sheets, I want to move the data to different sheet with all of the groups like the Group1 header and data below and Group2 header and data below.....and so on.
And some times I have only 2 groups in the sheet and some times I have 10 groups.
Thank you very much!
Reply With Quote
Archana[_2_]
View Public Profile
Find all posts by Archana[_2_]