lookup physical first worksheet
Hi,
I don't know what is happening on your workbook actually but try this:
Sub Test()
Dim Numsheets As Integer
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Numsheets = Worksheets.Count
Sheets(Numsheets - 1).Copy Befo=Sheets(Numsheets - 1)
Application.EnableEvents = True
End Sub
'Run this after the above test.
Sub RestoreSettings()
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub
if something changes, then there is a possibility that calculation of
your formula or some event procedures affect the macro.
I guess there might be a circular reference after copying the sheet.
--
HTH,
okaizawa
RichP wrote:
The code in the function worked well until now. I have taken out the
original first sheet and I believe that it looks for this sheet, I
don't really know.
When executing the following line an error occurs and the program seems
to be looping continuously through the function.
The code is Sheets(Numsheets-1).copy Befo=Sheets(Numsheets-1)
'Where Numsheets = worksheets.count
Which is supposed to copy the last but one sheet and paste the new
sheet just before the last one, As I said this all worked fine until I
moved the original sheet.
I hope this makes sence and someone can help
|