Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: Data Loss, have prev. copy of sheet nastech Excel Discussion (Misc queries) 1 June 20th 07 03:00 PM
Stop the loop when found. hfazal Excel Programming 1 February 16th 06 11:57 PM
Hot key to stop a LOOP joopdog[_3_] Excel Programming 5 February 9th 06 06:51 PM
how to stop a loop L775 Excel Programming 6 November 29th 04 08:37 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"