Hello,
I am having trouble with a Loop and I am hoping someone will have some insight.
I have a For x = 1 To x-1, Next x loop. The Macro loops through the active sheets and deletes sheets with a given criteria. My problem is...when a sheet is deleted my x is not recalculating when a sheet is deleted. x = ActiveWorkbook.Sheets.Count
My Code is:
"Sub WhAAAAt()
Application.DisplayAlerts = False
LastCell = ActiveCell.SpecialCells(xlLastCell).Address
x = ActiveWorkbook.Sheets.Count
For x = 1 To MyCount - 1
LastCell = ActiveCell.SpecialCells(xlLastCell).Address
If LastCell = "$T$10" Or LastCell = "$T$11" Then
ActiveWindow.SelectedSheets.Delete
End If
ActiveSheet.Next.Activate
Next x
Application.DisplayAlerts = True
End Sub"
Any Help would be greatly appreciated.
Lee
I am having trouble with a Loop and I am hoping someone will have some insight.
I have a For x = 1 To x-1, Next x loop. The Macro loops through the active sheets and deletes sheets with a given criteria. My problem is...when a sheet is deleted my x is not recalculating when a sheet is deleted. x = ActiveWorkbook.Sheets.Count
My Code is:
"Sub WhAAAAt()
Application.DisplayAlerts = False
LastCell = ActiveCell.SpecialCells(xlLastCell).Address
x = ActiveWorkbook.Sheets.Count
For x = 1 To MyCount - 1
LastCell = ActiveCell.SpecialCells(xlLastCell).Address
If LastCell = "$T$10" Or LastCell = "$T$11" Then
ActiveWindow.SelectedSheets.Delete
End If
ActiveSheet.Next.Activate
Next x
Application.DisplayAlerts = True
End Sub"
Any Help would be greatly appreciated.
Lee