Hi all,
I need some help in tweaking the code below. I have changed the text colour to red for the parts which i believe are the problem.
The second time the macro is run, the new sheet that is created is sheet8. So the part of this code that refers to sheet 7 to rename it, doesnt work.
How can i have the new sheet renamed whichever sheet number excel happens to assign it?
I need some help in tweaking the code below. I have changed the text colour to red for the parts which i believe are the problem.
Code:
Sub MSvone()
'
' MSvone Macro
Sheets("Sheet1").Select
ActiveSheet.ListObjects("Table_Query_from_Sage_Accounts_2011_1").Range. _
AutoFilter Field:=1, Criteria1:="=*00", Operator:=xlOr, Criteria2:= _
"=*all*"
Cells.Select
Selection.Copy
[COLOR=red]Sheets.Add After:=Sheets(Sheets.Count)[/COLOR]
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
, SkipBlanks:=False, Transpose:=False
[COLOR=red] Sheets("Sheet7").Select[/COLOR]
[COLOR=red] Sheets("Sheet7").Name = "Marshall Street"[/COLOR]
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
End Sub
The second time the macro is run, the new sheet that is created is sheet8. So the part of this code that refers to sheet 7 to rename it, doesnt work.
How can i have the new sheet renamed whichever sheet number excel happens to assign it?