Hi Guys
I had some help yesterday in getting some code to rename a new sheet, regardless of which sheetnumber excel assigns it.
Now, when i have replicated the code - because i want to create more than 1 new sheet, i get the error "Duplicate declaration in current scope".
As you can see, what im trying to do is create a seperate sheet for the data on sheet1 after a filter has been applied. And then afterwards it goes through and deletes all hidden rows.
I ultimately have about 25 filters to apply to the data and require a new sheet for each one. But i think if we can get the code right for the first couple, then i should be able to manage on my own.
Thanks
I had some help yesterday in getting some code to rename a new sheet, regardless of which sheetnumber excel assigns it.
Now, when i have replicated the code - because i want to create more than 1 new sheet, i get the error "Duplicate declaration in current scope".
Code:
Selection.AutoFilter
ActiveSheet.ListObjects("Table_Query_from_Sage_Accounts_2011_1").Range. _
AutoFilter Field:=1, Criteria1:="=*00", Operator:=xlOr, Criteria2:= _
"=*all*"
Cells.Select
Selection.Copy
Dim a As Worksheet
Set a = Sheets.Add(After:=Sheets(Sheets.Count))
a.Name = "Marshall Street"
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
, SkipBlanks:=False, Transpose:=False
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Columns("B:B").Select
Sheets("Sheet1").Select
Range("b4").Select
ActiveSheet.ListObjects("Table_Query_from_Sage_Accounts_2011_1").Range. _
AutoFilter Field:=1, Criteria1:="=*01", Operator:=xlOr, Criteria2:= _
"=*all*"
Cells.Select
Selection.Copy
Dim a As Worksheet
Set a = Sheets.Add(After:=Sheets(Sheets.Count))
a.Name = "Roundhay Road"
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
, SkipBlanks:=False, Transpose:=False
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Columns("B:B").Select
Sheets("Sheet1").Select
Range("b4").Select
Selection.AutoFilter
For Each ws In Sheets
If ws.Name <> "sheet 1" Then
LR = ws.UsedRange.Rows(ws.UsedRange.Rows.Count).Row
For i = LR To 2 Step -1
If ws.Cells(i, 7).EntireRow.Hidden = True Then ws.Cells(i, 7).EntireRow.Delete
Next i
End If
Next ws
As you can see, what im trying to do is create a seperate sheet for the data on sheet1 after a filter has been applied. And then afterwards it goes through and deletes all hidden rows.
I ultimately have about 25 filters to apply to the data and require a new sheet for each one. But i think if we can get the code right for the first couple, then i should be able to manage on my own.
Thanks