Thread: Add worksheet
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Henry[_5_] Henry[_5_] is offline
external usenet poster
 
Posts: 104
Default Add worksheet

Shockley,

The previous condition is If N47 AND sht = 1
The ElseIf will be executed if sht = 2 (or more) even if N is 47.

HTH
Henry

"shockley" wrote in message
...
If N 47 And sht = 1 Then
sht = 2: N = 6
ElseIf N 52 And sht = 2 Then
sht = sht + 1: N = 6
End If


You will never get to the "ElseIf N 52" since the previously specified
condition "N 47" p will already be met.

Perhaps you want the first condition to be "N 47 And N <= 52" ?

HTH,
Shockley


"CAA" wrote in message
...
Hello, Merry Christmas to you and a happy new year.

I am trying to add a worksheet template to a workbook if and when it is
needed. I don't seem to be able to get it right.
I cycle through about 12 rows on the first sheet, then 24 on the 2nd.
The 2nd sheet is identicle to the template i want to add. There may be
a far easier method here.
I would like to add the sheet when i've got to the end of sheet2, name
that sheet 3, 4 or 5? and put it to the end.

So far i've magaged this, but something's not right.

Private Sub Image11_Click()
N = N + 2
If N 47 And sht = 1 Then
sht = 2: N = 6
ElseIf N 52 And sht = 2 Then
sht = sht + 1: N = 6
End If

If Sheets.Count sht And N = 52 Then
Call Addsht
Else

End If
Label19.Caption = Sheets("Sheet" & sht).Cells(N, 1)
Call getinf

End Sub

Thanks for looking
CAA


---
Message posted from http://www.ExcelForum.com/