Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
stop loop if prev sheet does not exist
Hi,
How do I stop following loop if prev sheet does not exist? It should still make Application.DisplayAlerts = true ?? T ---------------------- Application.DisplayAlerts = False x = 6 Do While Cells(x, 2).Value < "" Sheets("makron").Activate ActiveSheet.Previous.Select ActiveSheet.Delete x = x + 1 Loop |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
stop loop if prev sheet does not exist
Something like this:
Private Sub CommandButton1_Click() Dim RowCount As Long Dim i As Long With Range("rngStart") RowCount = .End(xlDown).Row - 1 - .Row End With With Worksheets("makron") If RowCount .Index - 1 Then MsgBox "Not enough sheets" Exit Sub End If Application.DisplayAlerts = False For i = 1 To RowCount Worksheets(.Index - 1).Delete Next Application.DisplayAlerts = True End With End Sub NickHK "sverre" wrote in message ... Hi, How do I stop following loop if prev sheet does not exist? It should still make Application.DisplayAlerts = true ?? T ---------------------- Application.DisplayAlerts = False x = 6 Do While Cells(x, 2).Value < "" Sheets("makron").Activate ActiveSheet.Previous.Select ActiveSheet.Delete x = x + 1 Loop |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help: Data Loss, have prev. copy of sheet | Excel Discussion (Misc queries) | |||
Stop the loop when found. | Excel Programming | |||
Hot key to stop a LOOP | Excel Programming | |||
how to stop a loop | Excel Programming | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming |