hello experts,
I've an automatic macro that initiates when the file opens, it works perfectly when I just open the file, but it doesn't work if another not related macro create this excel file and opens it, in this case it gives and runtime error 1004 - method range of object global falied
and yellow row marked : "If Range("MakeCode") = "" And ActiveWorkbook.Name <> "NextLevelCareer.xlsm" Then"
it looks like the code is failing before the file get the chance to open, but if I just click on the file it opens first and then initiate the code perfectly, if this is the case how can I fix it please?
thanks for any help.
Code
Private Sub Workbook_Open()
If Range("MakeCode") = "" And ActiveWorkbook.Name <> "NextLevelCareer.xlsm" Then 'here it stuck.
Application.Goto Reference:="CREATEDATE"
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("I24").Select
Application.Goto Reference:="CREATEDATE"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.Goto Reference:="UPDATEDATE"
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("G24").Select
Application.Goto Reference:="UPDATEDATE"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.Goto Reference:="makecode2"
Selection.Copy
Application.Goto Reference:="MakeCode"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.Goto Reference:="makecode2"
Application.CutCopyMode = False
Selection.ClearContents
Application.Goto Reference:="R1C1"
End Sub
Display More
Quote