Cinema
03-18-2019, 02:51 AM
Hi,
Im getting an error "Subscript out of range" as the worksheet does not exist. But I have an error handling in my code but this does not apply.
Option Explicit
Public Sub Copy_Input()
Dim wbkInput As Workbook
Dim wbkBackup As Workbook
Dim wrsInput As Worksheet
Dim wrsBackup As Worksheet
Dim Path As String
Dim Dateiname As String
Dim strBerichtsmonat As String
Dim strFormulaNewMonth As String
Dim int_AktuellerMonat As Integer
Dim int_AktuellesJahr As Integer
Dim intLastRow As Integer
Dim intLength As Integer
Dim i, LengthRange As Long
Dim aryPfad As Variant
Dim arrayMonate As Variant
Dim varSearchInFormula As Variant
Dim fbCalcMode As XlCalculation
Dim BackUpRange As Range
arrayMonate = Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember")
Set wbkBackup = Application.ActiveWorkbook
strBerichtsmonat = arrayMonate(1)
Set wrsBackup = wbkBackup.Worksheets(strBerichtsmonat) <---- ERROR
If wrsBackup Is Nothing Then
MsgBox "Sheet does not exist"
Exit Sub
End If
Im getting an error "Subscript out of range" as the worksheet does not exist. But I have an error handling in my code but this does not apply.
Option Explicit
Public Sub Copy_Input()
Dim wbkInput As Workbook
Dim wbkBackup As Workbook
Dim wrsInput As Worksheet
Dim wrsBackup As Worksheet
Dim Path As String
Dim Dateiname As String
Dim strBerichtsmonat As String
Dim strFormulaNewMonth As String
Dim int_AktuellerMonat As Integer
Dim int_AktuellesJahr As Integer
Dim intLastRow As Integer
Dim intLength As Integer
Dim i, LengthRange As Long
Dim aryPfad As Variant
Dim arrayMonate As Variant
Dim varSearchInFormula As Variant
Dim fbCalcMode As XlCalculation
Dim BackUpRange As Range
arrayMonate = Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember")
Set wbkBackup = Application.ActiveWorkbook
strBerichtsmonat = arrayMonate(1)
Set wrsBackup = wbkBackup.Worksheets(strBerichtsmonat) <---- ERROR
If wrsBackup Is Nothing Then
MsgBox "Sheet does not exist"
Exit Sub
End If