Duplicating Macro slow

JVID

New Member
Joined
Jan 9, 2013
Messages
39
I have a macro that duplicates a template several times. I turn off calculations and when I'm about 100 of 800 worksheets in it gets VERY slow.

Any advice? Anything I can do?

Thanks,

John
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Did I read correctly that you have 800 worksheets in the same file?
If not, please explain greater detail please.
 
Upvote 0
Yes- I did. It's more like 1000 because I run to scriptsExcel allows you to exceed a limit when you are duplicating.

any insight into how to speed up the macro?

JV
 
Last edited:
Upvote 0
1000 sheets to me sound like a recipe for distaster. But in the end, I'm not the one using this ;-)
Did you turn off ScreenUpdating as well?
Is your code optimised in the sense that duplicating only 1 sheet is in the best possible way?
Do you free up resources in your code that you do not need anymore?
 
Upvote 0
Hey it worked once it finished! haha thanks for the concern.

can you tell me how to do each of those?

J
 
Upvote 0
Code:
Application.ScreenUpdating = False
'your code
Application.ScreenUpdating = True
 
Upvote 0
Where would this code go in this example

Code:
Private Sub indexer()
Dim wSheet As Worksheet
Dim l As Long


l = 1


    With Me
        .Columns(1).ClearContents
        .Cells(1, 1) = "INDEX"
        .Cells(1, 1).Name = "Index"
    End With
    


    For Each wSheet In Worksheets
        If wSheet.Name <> Me.Name Then
            l = l + 1
                With wSheet
                    .Range("A1").Name = "Start_" & wSheet.Index
                    .Hyperlinks.Add Anchor:=.Range("A1"), Address:="", _
                    SubAddress:="Index", TextToDisplay:="Back to Index"
                End With


                Me.Hyperlinks.Add Anchor:=Me.Cells(l, 1), Address:="", _
                SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
        End If
    Next wSheet


End Sub
 
Upvote 0
Code:
Private Sub indexer()
Dim wSheet As Worksheet
Dim l As Long

Application.ScreenUpdating = False

l = 1

    With Me
        .Columns(1).ClearContents
        .Cells(1, 1) = "INDEX"
        .Cells(1, 1).Name = "Index"
    End With
    
    For Each wSheet In Worksheets
        If wSheet.Name <> Me.Name Then
            l = l + 1
                With wSheet
                    .Range("A1").Name = "Start_" & wSheet.Index
                    .Hyperlinks.Add Anchor:=.Range("A1"), Address:="", _
                    SubAddress:="Index", TextToDisplay:="Back to Index"
                End With


                Me.Hyperlinks.Add Anchor:=Me.Cells(l, 1), Address:="", _
                SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
        End If
    Next wSheet


End Sub

Application.ScreenUpdating = True
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,335
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top