Macro only runs for 5 steps and then stops. No error or anything. It behaves like there is "exit sub" after the 5th step

Xalova

Board Regular
Joined
Feb 11, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Like the title says. i written a code which lets me add sheets and rename them accordingly. But since i changed something yesterday (i dont know what exactly) it just doesnt run properly anymore.

that is the code:

VBA Code:
Sub DeleteSheetsBetweenFirstAndLastMarkerSheets()
'Updateby Extendoffice
On Error GoTo Errorhandler
    Dim ws As Worksheet
    Set wh = Worksheets(ActiveSheet.Name)
    With Worksheets("Vorlage").Range("AnzahlTage")
        .Value = .Value + 1

    Sheets("Vorlage").Copy before:=Worksheets("YARA")
    
    If IsNumeric(.Value) Then
    'ActiveSheet.Name = "Tag " & .Value
    ActiveSheet.Name = "t" & .Value
    'Sheets("Tag " & .Value).Tab.ColorIndex = 10
    'Sheets(.Value).Tab.ColorIndex = 10
    .Value = .Value + 1
    End If
    GoTo ciao
Errorhandler:
        MsgBox "Befehl konnte nicht ausgeführt werden, da es die tabelle mit dem namen """ & .Value & """ schon exisitiert"
        'MsgBox "Befehl konnte nicht ausgeführt werden, da es die tabelle mit dem namen ""Tag " & .Value & """schon exisitiert"
    End With
ciao:
End Sub

in the code are many things commented out, to try new things but it didnt really work. does anyone have any idea?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Using On Error Goto is not such a great idea to find out where is your logic glitch !​
As it could be done without just using the worksheet function ISREF …​
 
Upvote 0
Using On Error Goto is not such a great idea to find out where is your logic glitch !​
As it could be done without just using the worksheet function ISREF …​
i tried to comment out the On Error Goto. it didnt change anything
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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