View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Harshad[_2_] Harshad[_2_] is offline
external usenet poster
 
Posts: 44
Default Problem when insert sheets by macro

Dear Mike,

Your code also works very nicely when the sheet3 is active sheet, in case
of Roger, if any sheet is active the code runs very smoothly. My mean to say
that,
When i open new excel file, by default 3 sheet file opens, on which Sheet1
is active.
If i use your code on sheet1, the result is Sheet1, sheet4,
sheet5,.........,Sheet2, Sheet3.


Thank you
"Mike H" wrote:

And this is different to the solution I proposed!! My confusion grows.

"Harshad" wrote:

Thank you roger,

Its working nicely.


"Roger Govier" wrote:

Hi

Try
Sub Sheet_addition()
Dim i As Long
On Error GoTo endit
Application.ScreenUpdating = False
For i = 1 To 52
Sheets.Add after:=Sheets(i)
Next i
endit:
Application.ScreenUpdating = True
End Sub

--
Regards
Roger Govier

"Harshad" wrote in message
...
When i run following macro on the sheet 1, all the sheet comes in reverse
direction, means, sheet6, sheet5, sheet4,....Sheet1. i want it as sheet1,
sheet2, sheet3, sheet4, sheet5, sheet6.............etc

The macro i got from this discussion group is as:

Sub Sheet_addition()
Dim i As Long
On Error GoTo endit
Application.ScreenUpdating = False
For i = 1 To 52
Sheets.Add
Next i
endit:
Application.ScreenUpdating = True
End Sub