Hello, please i need help i constantly getting subscript out of range error and i dont know why this is my code (i'm begginer)
Sub PrvyPokus()
Dim dátum As String
Dim TotalNLos, Loss10 As Integer
Dim GrossLoss As Long
Workbooks.Open ("R:\93824000 - Riadenie rizík - Skupina SR\VRM Folders\OpRisk a BCM\xMichal ****a\Dashboard\Dashboard_graf -aug_IRR.xlsm")
Workbooks.Open("R:\93824000 - Riadenie rizík - Skupina SR\VRM Folders\OpRisk a BCM\xMichal ****a\Dashboard\SAP.xlsx").Activate
Sheets("report1").Move after:=Workbooks("Dashboard_graf -aug_IRR.xlsm").Sheets("Graf Neg. Loss")
'report2 is giving me the error but when I write "worksheets("name").activate" it will work
Sheets("report2").Move after:=Workbooks("Dashboard_graf -aug_IRR.xlsm").Sheets("Graf Neg. Loss")
ActiveWorkbook.Close savechanges:=False
Workbooks.Open("R:\93824000 - Riadenie rizík - Skupina SR\VRM Folders\OpRisk a BCM\xMichal ****a\Dashboard\LORD - Operation risk dpt. _monthly.xls").Activate
'but this line of code belove is not working after i write that mentioned code and this will not work even if i write the same code "worksheets("name").activate"
Sheets("Negative Losses").Move after:=Workbooks("Dashboard_graf -aug_IRR.xlsm").Sheets("Graf Neg. Loss")
ActiveWorkbook.Close savechanges:=False
Workbooks("Dashboard_graf -aug_IRR").Activate
Sheets("Negative Losses").Activate
GrossLoss = Range("CVNŠ")
TotalNLos = Range("PNŠ")
Loss10 = Range("PNŠvýš10k")
dátum = InputBox("Zadajte dátum")
Sheets("Graf Neg. Loss").Activate
Range("A2").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = dátum
ActiveCell.Offset(0, 1) = TotalNLos
ActiveCell.Offset(0, 2) = Loss10
ActiveCell.Offset(0, 3) = GrossLoss
End Sub
When i try to run this i'm getting that error. But the funny thing is when im clicking on "step into" through the code it works and it is doing what i want it to do. Thins is really confusing and frustrating. Please help. Thank you
Sub PrvyPokus()
Dim dátum As String
Dim TotalNLos, Loss10 As Integer
Dim GrossLoss As Long
Workbooks.Open ("R:\93824000 - Riadenie rizík - Skupina SR\VRM Folders\OpRisk a BCM\xMichal ****a\Dashboard\Dashboard_graf -aug_IRR.xlsm")
Workbooks.Open("R:\93824000 - Riadenie rizík - Skupina SR\VRM Folders\OpRisk a BCM\xMichal ****a\Dashboard\SAP.xlsx").Activate
Sheets("report1").Move after:=Workbooks("Dashboard_graf -aug_IRR.xlsm").Sheets("Graf Neg. Loss")
'report2 is giving me the error but when I write "worksheets("name").activate" it will work
Sheets("report2").Move after:=Workbooks("Dashboard_graf -aug_IRR.xlsm").Sheets("Graf Neg. Loss")
ActiveWorkbook.Close savechanges:=False
Workbooks.Open("R:\93824000 - Riadenie rizík - Skupina SR\VRM Folders\OpRisk a BCM\xMichal ****a\Dashboard\LORD - Operation risk dpt. _monthly.xls").Activate
'but this line of code belove is not working after i write that mentioned code and this will not work even if i write the same code "worksheets("name").activate"
Sheets("Negative Losses").Move after:=Workbooks("Dashboard_graf -aug_IRR.xlsm").Sheets("Graf Neg. Loss")
ActiveWorkbook.Close savechanges:=False
Workbooks("Dashboard_graf -aug_IRR").Activate
Sheets("Negative Losses").Activate
GrossLoss = Range("CVNŠ")
TotalNLos = Range("PNŠ")
Loss10 = Range("PNŠvýš10k")
dátum = InputBox("Zadajte dátum")
Sheets("Graf Neg. Loss").Activate
Range("A2").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = dátum
ActiveCell.Offset(0, 1) = TotalNLos
ActiveCell.Offset(0, 2) = Loss10
ActiveCell.Offset(0, 3) = GrossLoss
End Sub
When i try to run this i'm getting that error. But the funny thing is when im clicking on "step into" through the code it works and it is doing what i want it to do. Thins is really confusing and frustrating. Please help. Thank you