O
oakman
Greetings,
I am not at all experienced in VBA, but I thought that I’d give this
shot. However, I cannot get it to work. I have a file in which th
first four sheets are permanent. Other sheets are created every mornin
depending on a set of conditions. The number of sheets being created i
different every day. I am trying to come up with a code that woul
delete every sheet after sheet 4Can some one please take a look at m
code and help me. I would appreciate it very much! Currently, I get
Compile error for the word “Worksheets” in the line “Set Sh
Worksheets(Array(1), (2), (3), (4))” Not quite sure what that reall
means. Thank you
Sub deletesheet()
Dim x As Integer
Dim Sh As Worksheet
Dim Daysheet As Worksheet
Dim WrkBook As Workbook
x = 1
Set Sh = Worksheets(Array(1), (2), (3), (4))
Set WrkBook = Currentfile
For Each Daysheet In WrkBook
Worksheets.Delete After:=Sh
Next x
x = x + 1
End Su
I am not at all experienced in VBA, but I thought that I’d give this
shot. However, I cannot get it to work. I have a file in which th
first four sheets are permanent. Other sheets are created every mornin
depending on a set of conditions. The number of sheets being created i
different every day. I am trying to come up with a code that woul
delete every sheet after sheet 4Can some one please take a look at m
code and help me. I would appreciate it very much! Currently, I get
Compile error for the word “Worksheets” in the line “Set Sh
Worksheets(Array(1), (2), (3), (4))” Not quite sure what that reall
means. Thank you
Sub deletesheet()
Dim x As Integer
Dim Sh As Worksheet
Dim Daysheet As Worksheet
Dim WrkBook As Workbook
x = 1
Set Sh = Worksheets(Array(1), (2), (3), (4))
Set WrkBook = Currentfile
For Each Daysheet In WrkBook
Worksheets.Delete After:=Sh
Next x
x = x + 1
End Su