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
71
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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,758
Office Version
  1. 2010
Platform
  1. Windows
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 …​
 

Xalova

Board Regular
Joined
Feb 11, 2021
Messages
71
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
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
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,578
Messages
5,765,205
Members
425,266
Latest member
bishopc22

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
Top