Code Runs Only If Visual Basic Editor is Open











up vote
0
down vote

favorite












I have a really weird problem about VBA.
I tried to list circular references at activeworkbook and i have written below code for that. It only works if i press ALT+F11. So if VBA Editor window is open, code runs correctly but otherwise it is not working.
By the way, code is in a module at Addin and i call it from ribbon. You may see the code below.
Your help is highly appreciated. Bruteforce solution works. I hope someone can find decent solution than me.



Type SaveRangeCir
Val As Variant
Addr As String
Preaddress As String
Shtname As String
Workbname As String
End Type
Public OldCir() As SaveRangeCir
Sub DonguselBasvurulariBul(control As IRibbonControl)

Dim wba As Workbook
Dim ws As Worksheet
Dim wsa As Worksheet
Dim sht As Worksheet
Dim sht2 As Worksheet
Dim dummy As Worksheet
Dim Item As Range
Dim crcell As Range
Dim cll As Range

un = "Sayin " & Environ("UserName")

muyarcirc = MsgBox("Lutfen Oncelikle Dosyanizi Kaydedin" & vbNewLine & vbNewLine & _
"-->> Dosyanizi Kaydettiniz mi?", vbExclamation + vbYesNo, un)

If muyarcirc = vbno Then
muyar2 = MsgBox("Dongusel Basvuru Arama Islemi Iptal Edildi", vbInformation, un)
Exit Sub
End If

'BruteForce Solution
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False

.VBE.MainWindow.Visible = True
.Wait Now + TimeValue("00:00:01")
.VBE.MainWindow.Visible = False
End With

On Error Resume Next

Set wba = ActiveWorkbook
Set wsa = wba.ActiveSheet

wba.Worksheets.Add

Set dummy = ActiveSheet

For Each sht2 In wba.Sheets
If sht2.Name = "Dongusel Basvurular" Then
sht2.Delete
End If
Next sht2

wba.Worksheets.Add

Set ws = wba.ActiveSheet

dummy.Delete

With ws
.Name = "Dongusel Basvurular"
.Range("A1") = "Dongusel Basvuru Hucresi"
.Range("B1") = "Dongusel Basvuru Hucresi Formul Degeri"
.Range("C1") = "Bagli Oldugu Alan"
.Range("D1") = "Bulundugu Sayfa"
.Range("E1") = "Bulundugu Dosya"
End With

With wba
For Each sht In .Worksheets
If sht.CodeName <> ws.CodeName Then
sht.Activate
crcell = Nothing

Do
Set crcell = sht.CircularReference

If Not crcell Is Nothing Then
ReDim Preserve OldCir(1 To crcell.Precedents.Cells.Count)

i = 0
For Each cll In crcell.Precedents
i = i + 1
OldCir(i).Addr = cll.Address
OldCir(i).Val = cll.Formula
OldCir(i).Preaddress = cll.Precedents.Address
OldCir(i).Shtname = cll.Parent.Name
OldCir(i).Workbname = cll.Parent.Parent.Name
cll.Value = cll.Value
Next cll
For j = LBound(OldCir) To UBound(OldCir)
lr = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(lr, 1) = OldCir(j).Addr
ws.Cells(lr, 2) = "'" & OldCir(j).Val
ws.Cells(lr, 3) = OldCir(j).Preaddress
ws.Cells(lr, 4) = OldCir(j).Shtname
ws.Cells(lr, 5) = OldCir(j).Workbname
ws.Hyperlinks.Add Anchor:=ws.Cells(lr, 1), Address:="", SubAddress:=ws.Cells(lr, 4) & "!" & ws.Cells(lr, 1), _
ScreenTip:="Dongusel Basvuru Hucresini Gormek icin Tiklayiniz"
Next j
Else
GoTo skipsheet
End If

Erase OldCir
Set crcell = sht.CircularReference

Loop While crcell.Cells.Count > 0

lr2 = ws.Cells(Rows.Count, 1).End(xlUp).Row
For m = 2 To lr2
If ActiveSheet.Name <> ws.Cells(lr2, "D") Then
wba.Sheets(ws.Cells(m, "D")).Activate
End If
Range(ws.Cells(m, 1)).Formula = "=" & Right(ws.Cells(m, 2), Len(ws.Cells(m, 2)) - 1)
Next m
End If
skipsheet:
Next sht

If ws.Range("A2") = "" Then
ws.Delete
wsa.Activate
m1 = MsgBox("Aktif Dosyada Dongusel Basvuru Bulunamadi", vbInformation, "Sayin " & Environ("UserName"))
Else
ws.Activate
ws.Range("A1:E1").EntireColumn.AutoFit
End If
End With

Erase OldCir
Set crcell = Nothing

With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub









share|improve this question




















  • 4




    Using On Error Resume Next hides all error messages, but the errors still occur, you just cannot see them. You can't fix your errors if you don't see them. Remove that line and fix your errors! • Additionally I recommend to activate Option Explicit: In the VBA editor go to ToolsOptionsRequire Variable Declaration. • After that I recommend to read VBA Error Handling – A Complete Guide in case you need to implement a good error handling.
    – Pᴇʜ
    Nov 20 at 11:12








  • 1




    What do you mean by "not working"? Doesn't run at all, doesn't do what it should, causes an error, or something else?
    – Rory
    Nov 20 at 11:12










  • Actually i tried to avoid errors while setting the circular references. Thats why i am using on error resume next statement. My problem is if i open VBA Editor window i get results which is a list of circular references but if VBA Editor is not opened there is no list at same workbook. I would like to give extra information. Code sits in an encrypted module in addin. thank you for your help
    – MehmetCanbulat
    Nov 20 at 11:20












  • Thanks Rory for your help. Actually code runs well but i received different result whether VBA Editor window is visible or not
    – MehmetCanbulat
    Nov 20 at 11:35






  • 1




    You still shouldn't just put OERN at the top of the code and then hope for the best. Use it only for the time required and then reset error handling as soon as you can. Also, you need to be specific as to what the "different results" are, and where in the add-in the code is located.
    – Rory
    Nov 20 at 11:57















up vote
0
down vote

favorite












I have a really weird problem about VBA.
I tried to list circular references at activeworkbook and i have written below code for that. It only works if i press ALT+F11. So if VBA Editor window is open, code runs correctly but otherwise it is not working.
By the way, code is in a module at Addin and i call it from ribbon. You may see the code below.
Your help is highly appreciated. Bruteforce solution works. I hope someone can find decent solution than me.



Type SaveRangeCir
Val As Variant
Addr As String
Preaddress As String
Shtname As String
Workbname As String
End Type
Public OldCir() As SaveRangeCir
Sub DonguselBasvurulariBul(control As IRibbonControl)

Dim wba As Workbook
Dim ws As Worksheet
Dim wsa As Worksheet
Dim sht As Worksheet
Dim sht2 As Worksheet
Dim dummy As Worksheet
Dim Item As Range
Dim crcell As Range
Dim cll As Range

un = "Sayin " & Environ("UserName")

muyarcirc = MsgBox("Lutfen Oncelikle Dosyanizi Kaydedin" & vbNewLine & vbNewLine & _
"-->> Dosyanizi Kaydettiniz mi?", vbExclamation + vbYesNo, un)

If muyarcirc = vbno Then
muyar2 = MsgBox("Dongusel Basvuru Arama Islemi Iptal Edildi", vbInformation, un)
Exit Sub
End If

'BruteForce Solution
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False

.VBE.MainWindow.Visible = True
.Wait Now + TimeValue("00:00:01")
.VBE.MainWindow.Visible = False
End With

On Error Resume Next

Set wba = ActiveWorkbook
Set wsa = wba.ActiveSheet

wba.Worksheets.Add

Set dummy = ActiveSheet

For Each sht2 In wba.Sheets
If sht2.Name = "Dongusel Basvurular" Then
sht2.Delete
End If
Next sht2

wba.Worksheets.Add

Set ws = wba.ActiveSheet

dummy.Delete

With ws
.Name = "Dongusel Basvurular"
.Range("A1") = "Dongusel Basvuru Hucresi"
.Range("B1") = "Dongusel Basvuru Hucresi Formul Degeri"
.Range("C1") = "Bagli Oldugu Alan"
.Range("D1") = "Bulundugu Sayfa"
.Range("E1") = "Bulundugu Dosya"
End With

With wba
For Each sht In .Worksheets
If sht.CodeName <> ws.CodeName Then
sht.Activate
crcell = Nothing

Do
Set crcell = sht.CircularReference

If Not crcell Is Nothing Then
ReDim Preserve OldCir(1 To crcell.Precedents.Cells.Count)

i = 0
For Each cll In crcell.Precedents
i = i + 1
OldCir(i).Addr = cll.Address
OldCir(i).Val = cll.Formula
OldCir(i).Preaddress = cll.Precedents.Address
OldCir(i).Shtname = cll.Parent.Name
OldCir(i).Workbname = cll.Parent.Parent.Name
cll.Value = cll.Value
Next cll
For j = LBound(OldCir) To UBound(OldCir)
lr = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(lr, 1) = OldCir(j).Addr
ws.Cells(lr, 2) = "'" & OldCir(j).Val
ws.Cells(lr, 3) = OldCir(j).Preaddress
ws.Cells(lr, 4) = OldCir(j).Shtname
ws.Cells(lr, 5) = OldCir(j).Workbname
ws.Hyperlinks.Add Anchor:=ws.Cells(lr, 1), Address:="", SubAddress:=ws.Cells(lr, 4) & "!" & ws.Cells(lr, 1), _
ScreenTip:="Dongusel Basvuru Hucresini Gormek icin Tiklayiniz"
Next j
Else
GoTo skipsheet
End If

Erase OldCir
Set crcell = sht.CircularReference

Loop While crcell.Cells.Count > 0

lr2 = ws.Cells(Rows.Count, 1).End(xlUp).Row
For m = 2 To lr2
If ActiveSheet.Name <> ws.Cells(lr2, "D") Then
wba.Sheets(ws.Cells(m, "D")).Activate
End If
Range(ws.Cells(m, 1)).Formula = "=" & Right(ws.Cells(m, 2), Len(ws.Cells(m, 2)) - 1)
Next m
End If
skipsheet:
Next sht

If ws.Range("A2") = "" Then
ws.Delete
wsa.Activate
m1 = MsgBox("Aktif Dosyada Dongusel Basvuru Bulunamadi", vbInformation, "Sayin " & Environ("UserName"))
Else
ws.Activate
ws.Range("A1:E1").EntireColumn.AutoFit
End If
End With

Erase OldCir
Set crcell = Nothing

With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub









share|improve this question




















  • 4




    Using On Error Resume Next hides all error messages, but the errors still occur, you just cannot see them. You can't fix your errors if you don't see them. Remove that line and fix your errors! • Additionally I recommend to activate Option Explicit: In the VBA editor go to ToolsOptionsRequire Variable Declaration. • After that I recommend to read VBA Error Handling – A Complete Guide in case you need to implement a good error handling.
    – Pᴇʜ
    Nov 20 at 11:12








  • 1




    What do you mean by "not working"? Doesn't run at all, doesn't do what it should, causes an error, or something else?
    – Rory
    Nov 20 at 11:12










  • Actually i tried to avoid errors while setting the circular references. Thats why i am using on error resume next statement. My problem is if i open VBA Editor window i get results which is a list of circular references but if VBA Editor is not opened there is no list at same workbook. I would like to give extra information. Code sits in an encrypted module in addin. thank you for your help
    – MehmetCanbulat
    Nov 20 at 11:20












  • Thanks Rory for your help. Actually code runs well but i received different result whether VBA Editor window is visible or not
    – MehmetCanbulat
    Nov 20 at 11:35






  • 1




    You still shouldn't just put OERN at the top of the code and then hope for the best. Use it only for the time required and then reset error handling as soon as you can. Also, you need to be specific as to what the "different results" are, and where in the add-in the code is located.
    – Rory
    Nov 20 at 11:57













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a really weird problem about VBA.
I tried to list circular references at activeworkbook and i have written below code for that. It only works if i press ALT+F11. So if VBA Editor window is open, code runs correctly but otherwise it is not working.
By the way, code is in a module at Addin and i call it from ribbon. You may see the code below.
Your help is highly appreciated. Bruteforce solution works. I hope someone can find decent solution than me.



Type SaveRangeCir
Val As Variant
Addr As String
Preaddress As String
Shtname As String
Workbname As String
End Type
Public OldCir() As SaveRangeCir
Sub DonguselBasvurulariBul(control As IRibbonControl)

Dim wba As Workbook
Dim ws As Worksheet
Dim wsa As Worksheet
Dim sht As Worksheet
Dim sht2 As Worksheet
Dim dummy As Worksheet
Dim Item As Range
Dim crcell As Range
Dim cll As Range

un = "Sayin " & Environ("UserName")

muyarcirc = MsgBox("Lutfen Oncelikle Dosyanizi Kaydedin" & vbNewLine & vbNewLine & _
"-->> Dosyanizi Kaydettiniz mi?", vbExclamation + vbYesNo, un)

If muyarcirc = vbno Then
muyar2 = MsgBox("Dongusel Basvuru Arama Islemi Iptal Edildi", vbInformation, un)
Exit Sub
End If

'BruteForce Solution
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False

.VBE.MainWindow.Visible = True
.Wait Now + TimeValue("00:00:01")
.VBE.MainWindow.Visible = False
End With

On Error Resume Next

Set wba = ActiveWorkbook
Set wsa = wba.ActiveSheet

wba.Worksheets.Add

Set dummy = ActiveSheet

For Each sht2 In wba.Sheets
If sht2.Name = "Dongusel Basvurular" Then
sht2.Delete
End If
Next sht2

wba.Worksheets.Add

Set ws = wba.ActiveSheet

dummy.Delete

With ws
.Name = "Dongusel Basvurular"
.Range("A1") = "Dongusel Basvuru Hucresi"
.Range("B1") = "Dongusel Basvuru Hucresi Formul Degeri"
.Range("C1") = "Bagli Oldugu Alan"
.Range("D1") = "Bulundugu Sayfa"
.Range("E1") = "Bulundugu Dosya"
End With

With wba
For Each sht In .Worksheets
If sht.CodeName <> ws.CodeName Then
sht.Activate
crcell = Nothing

Do
Set crcell = sht.CircularReference

If Not crcell Is Nothing Then
ReDim Preserve OldCir(1 To crcell.Precedents.Cells.Count)

i = 0
For Each cll In crcell.Precedents
i = i + 1
OldCir(i).Addr = cll.Address
OldCir(i).Val = cll.Formula
OldCir(i).Preaddress = cll.Precedents.Address
OldCir(i).Shtname = cll.Parent.Name
OldCir(i).Workbname = cll.Parent.Parent.Name
cll.Value = cll.Value
Next cll
For j = LBound(OldCir) To UBound(OldCir)
lr = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(lr, 1) = OldCir(j).Addr
ws.Cells(lr, 2) = "'" & OldCir(j).Val
ws.Cells(lr, 3) = OldCir(j).Preaddress
ws.Cells(lr, 4) = OldCir(j).Shtname
ws.Cells(lr, 5) = OldCir(j).Workbname
ws.Hyperlinks.Add Anchor:=ws.Cells(lr, 1), Address:="", SubAddress:=ws.Cells(lr, 4) & "!" & ws.Cells(lr, 1), _
ScreenTip:="Dongusel Basvuru Hucresini Gormek icin Tiklayiniz"
Next j
Else
GoTo skipsheet
End If

Erase OldCir
Set crcell = sht.CircularReference

Loop While crcell.Cells.Count > 0

lr2 = ws.Cells(Rows.Count, 1).End(xlUp).Row
For m = 2 To lr2
If ActiveSheet.Name <> ws.Cells(lr2, "D") Then
wba.Sheets(ws.Cells(m, "D")).Activate
End If
Range(ws.Cells(m, 1)).Formula = "=" & Right(ws.Cells(m, 2), Len(ws.Cells(m, 2)) - 1)
Next m
End If
skipsheet:
Next sht

If ws.Range("A2") = "" Then
ws.Delete
wsa.Activate
m1 = MsgBox("Aktif Dosyada Dongusel Basvuru Bulunamadi", vbInformation, "Sayin " & Environ("UserName"))
Else
ws.Activate
ws.Range("A1:E1").EntireColumn.AutoFit
End If
End With

Erase OldCir
Set crcell = Nothing

With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub









share|improve this question















I have a really weird problem about VBA.
I tried to list circular references at activeworkbook and i have written below code for that. It only works if i press ALT+F11. So if VBA Editor window is open, code runs correctly but otherwise it is not working.
By the way, code is in a module at Addin and i call it from ribbon. You may see the code below.
Your help is highly appreciated. Bruteforce solution works. I hope someone can find decent solution than me.



Type SaveRangeCir
Val As Variant
Addr As String
Preaddress As String
Shtname As String
Workbname As String
End Type
Public OldCir() As SaveRangeCir
Sub DonguselBasvurulariBul(control As IRibbonControl)

Dim wba As Workbook
Dim ws As Worksheet
Dim wsa As Worksheet
Dim sht As Worksheet
Dim sht2 As Worksheet
Dim dummy As Worksheet
Dim Item As Range
Dim crcell As Range
Dim cll As Range

un = "Sayin " & Environ("UserName")

muyarcirc = MsgBox("Lutfen Oncelikle Dosyanizi Kaydedin" & vbNewLine & vbNewLine & _
"-->> Dosyanizi Kaydettiniz mi?", vbExclamation + vbYesNo, un)

If muyarcirc = vbno Then
muyar2 = MsgBox("Dongusel Basvuru Arama Islemi Iptal Edildi", vbInformation, un)
Exit Sub
End If

'BruteForce Solution
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False

.VBE.MainWindow.Visible = True
.Wait Now + TimeValue("00:00:01")
.VBE.MainWindow.Visible = False
End With

On Error Resume Next

Set wba = ActiveWorkbook
Set wsa = wba.ActiveSheet

wba.Worksheets.Add

Set dummy = ActiveSheet

For Each sht2 In wba.Sheets
If sht2.Name = "Dongusel Basvurular" Then
sht2.Delete
End If
Next sht2

wba.Worksheets.Add

Set ws = wba.ActiveSheet

dummy.Delete

With ws
.Name = "Dongusel Basvurular"
.Range("A1") = "Dongusel Basvuru Hucresi"
.Range("B1") = "Dongusel Basvuru Hucresi Formul Degeri"
.Range("C1") = "Bagli Oldugu Alan"
.Range("D1") = "Bulundugu Sayfa"
.Range("E1") = "Bulundugu Dosya"
End With

With wba
For Each sht In .Worksheets
If sht.CodeName <> ws.CodeName Then
sht.Activate
crcell = Nothing

Do
Set crcell = sht.CircularReference

If Not crcell Is Nothing Then
ReDim Preserve OldCir(1 To crcell.Precedents.Cells.Count)

i = 0
For Each cll In crcell.Precedents
i = i + 1
OldCir(i).Addr = cll.Address
OldCir(i).Val = cll.Formula
OldCir(i).Preaddress = cll.Precedents.Address
OldCir(i).Shtname = cll.Parent.Name
OldCir(i).Workbname = cll.Parent.Parent.Name
cll.Value = cll.Value
Next cll
For j = LBound(OldCir) To UBound(OldCir)
lr = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ws.Cells(lr, 1) = OldCir(j).Addr
ws.Cells(lr, 2) = "'" & OldCir(j).Val
ws.Cells(lr, 3) = OldCir(j).Preaddress
ws.Cells(lr, 4) = OldCir(j).Shtname
ws.Cells(lr, 5) = OldCir(j).Workbname
ws.Hyperlinks.Add Anchor:=ws.Cells(lr, 1), Address:="", SubAddress:=ws.Cells(lr, 4) & "!" & ws.Cells(lr, 1), _
ScreenTip:="Dongusel Basvuru Hucresini Gormek icin Tiklayiniz"
Next j
Else
GoTo skipsheet
End If

Erase OldCir
Set crcell = sht.CircularReference

Loop While crcell.Cells.Count > 0

lr2 = ws.Cells(Rows.Count, 1).End(xlUp).Row
For m = 2 To lr2
If ActiveSheet.Name <> ws.Cells(lr2, "D") Then
wba.Sheets(ws.Cells(m, "D")).Activate
End If
Range(ws.Cells(m, 1)).Formula = "=" & Right(ws.Cells(m, 2), Len(ws.Cells(m, 2)) - 1)
Next m
End If
skipsheet:
Next sht

If ws.Range("A2") = "" Then
ws.Delete
wsa.Activate
m1 = MsgBox("Aktif Dosyada Dongusel Basvuru Bulunamadi", vbInformation, "Sayin " & Environ("UserName"))
Else
ws.Activate
ws.Range("A1:E1").EntireColumn.AutoFit
End If
End With

Erase OldCir
Set crcell = Nothing

With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub






excel vba circular-reference






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 13:07

























asked Nov 20 at 11:09









MehmetCanbulat

214




214








  • 4




    Using On Error Resume Next hides all error messages, but the errors still occur, you just cannot see them. You can't fix your errors if you don't see them. Remove that line and fix your errors! • Additionally I recommend to activate Option Explicit: In the VBA editor go to ToolsOptionsRequire Variable Declaration. • After that I recommend to read VBA Error Handling – A Complete Guide in case you need to implement a good error handling.
    – Pᴇʜ
    Nov 20 at 11:12








  • 1




    What do you mean by "not working"? Doesn't run at all, doesn't do what it should, causes an error, or something else?
    – Rory
    Nov 20 at 11:12










  • Actually i tried to avoid errors while setting the circular references. Thats why i am using on error resume next statement. My problem is if i open VBA Editor window i get results which is a list of circular references but if VBA Editor is not opened there is no list at same workbook. I would like to give extra information. Code sits in an encrypted module in addin. thank you for your help
    – MehmetCanbulat
    Nov 20 at 11:20












  • Thanks Rory for your help. Actually code runs well but i received different result whether VBA Editor window is visible or not
    – MehmetCanbulat
    Nov 20 at 11:35






  • 1




    You still shouldn't just put OERN at the top of the code and then hope for the best. Use it only for the time required and then reset error handling as soon as you can. Also, you need to be specific as to what the "different results" are, and where in the add-in the code is located.
    – Rory
    Nov 20 at 11:57














  • 4




    Using On Error Resume Next hides all error messages, but the errors still occur, you just cannot see them. You can't fix your errors if you don't see them. Remove that line and fix your errors! • Additionally I recommend to activate Option Explicit: In the VBA editor go to ToolsOptionsRequire Variable Declaration. • After that I recommend to read VBA Error Handling – A Complete Guide in case you need to implement a good error handling.
    – Pᴇʜ
    Nov 20 at 11:12








  • 1




    What do you mean by "not working"? Doesn't run at all, doesn't do what it should, causes an error, or something else?
    – Rory
    Nov 20 at 11:12










  • Actually i tried to avoid errors while setting the circular references. Thats why i am using on error resume next statement. My problem is if i open VBA Editor window i get results which is a list of circular references but if VBA Editor is not opened there is no list at same workbook. I would like to give extra information. Code sits in an encrypted module in addin. thank you for your help
    – MehmetCanbulat
    Nov 20 at 11:20












  • Thanks Rory for your help. Actually code runs well but i received different result whether VBA Editor window is visible or not
    – MehmetCanbulat
    Nov 20 at 11:35






  • 1




    You still shouldn't just put OERN at the top of the code and then hope for the best. Use it only for the time required and then reset error handling as soon as you can. Also, you need to be specific as to what the "different results" are, and where in the add-in the code is located.
    – Rory
    Nov 20 at 11:57








4




4




Using On Error Resume Next hides all error messages, but the errors still occur, you just cannot see them. You can't fix your errors if you don't see them. Remove that line and fix your errors! • Additionally I recommend to activate Option Explicit: In the VBA editor go to ToolsOptionsRequire Variable Declaration. • After that I recommend to read VBA Error Handling – A Complete Guide in case you need to implement a good error handling.
– Pᴇʜ
Nov 20 at 11:12






Using On Error Resume Next hides all error messages, but the errors still occur, you just cannot see them. You can't fix your errors if you don't see them. Remove that line and fix your errors! • Additionally I recommend to activate Option Explicit: In the VBA editor go to ToolsOptionsRequire Variable Declaration. • After that I recommend to read VBA Error Handling – A Complete Guide in case you need to implement a good error handling.
– Pᴇʜ
Nov 20 at 11:12






1




1




What do you mean by "not working"? Doesn't run at all, doesn't do what it should, causes an error, or something else?
– Rory
Nov 20 at 11:12




What do you mean by "not working"? Doesn't run at all, doesn't do what it should, causes an error, or something else?
– Rory
Nov 20 at 11:12












Actually i tried to avoid errors while setting the circular references. Thats why i am using on error resume next statement. My problem is if i open VBA Editor window i get results which is a list of circular references but if VBA Editor is not opened there is no list at same workbook. I would like to give extra information. Code sits in an encrypted module in addin. thank you for your help
– MehmetCanbulat
Nov 20 at 11:20






Actually i tried to avoid errors while setting the circular references. Thats why i am using on error resume next statement. My problem is if i open VBA Editor window i get results which is a list of circular references but if VBA Editor is not opened there is no list at same workbook. I would like to give extra information. Code sits in an encrypted module in addin. thank you for your help
– MehmetCanbulat
Nov 20 at 11:20














Thanks Rory for your help. Actually code runs well but i received different result whether VBA Editor window is visible or not
– MehmetCanbulat
Nov 20 at 11:35




Thanks Rory for your help. Actually code runs well but i received different result whether VBA Editor window is visible or not
– MehmetCanbulat
Nov 20 at 11:35




1




1




You still shouldn't just put OERN at the top of the code and then hope for the best. Use it only for the time required and then reset error handling as soon as you can. Also, you need to be specific as to what the "different results" are, and where in the add-in the code is located.
– Rory
Nov 20 at 11:57




You still shouldn't just put OERN at the top of the code and then hope for the best. Use it only for the time required and then reset error handling as soon as you can. Also, you need to be specific as to what the "different results" are, and where in the add-in the code is located.
– Rory
Nov 20 at 11:57

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391690%2fcode-runs-only-if-visual-basic-editor-is-open%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391690%2fcode-runs-only-if-visual-basic-editor-is-open%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'