Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Weird Behaviour Function not invoked

I see a weird behaviour in VBA code, not always but from time to time.
I've seen this in more than one workbook, so I'd like to know how to fix it.

Having (line numbers are just for explanation purposes)
001 For each cel in range("rTotal")
002 cel.offset(0,2)="x"
003 Next
.....
.....
100 Function anYthing( xLOL as string) as string
101 Application.Volatile True
102 Sheets("STAT").Select
103 Range("lVAL").Select
104 Sw = Sw + 1
105 If Sw 250 Then
106 MsgBox ("Times: " + Str(Sw))
107 End If
108 anYthing="anything"
109 Function End


While normal flow would be looping through steps 1 -2 -3 some times I can
see (while debugging) that flow is 1 - 2 - and looping (several times) steps
103 104 - 100, which is a function actually not invoked.
Eventually it goes back to 3-2-1

Any clue?

Sharon
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Weird Behaviour Function not invoked

I have noticed similar behavior when debugging. Although I could not
immediately see a reason, I have come to believe that it is a logic protocol
built into VBA that, in certain circumstances, VBA will check to see if there
is another part of the code that needs to do things like recalculate, run a
before event code, etc. It is the only explanation I could come up with.

"sharon" wrote:

I see a weird behaviour in VBA code, not always but from time to time.
I've seen this in more than one workbook, so I'd like to know how to fix it.

Having (line numbers are just for explanation purposes)
001 For each cel in range("rTotal")
002 cel.offset(0,2)="x"
003 Next
....
....
100 Function anYthing( xLOL as string) as string
101 Application.Volatile True
102 Sheets("STAT").Select
103 Range("lVAL").Select
104 Sw = Sw + 1
105 If Sw 250 Then
106 MsgBox ("Times: " + Str(Sw))
107 End If
108 anYthing="anything"
109 Function End


While normal flow would be looping through steps 1 -2 -3 some times I can
see (while debugging) that flow is 1 - 2 - and looping (several times) steps
103 104 - 100, which is a function actually not invoked.
Eventually it goes back to 3-2-1

Any clue?

Sharon

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Weird Behaviour Function not invoked

So far, is any MVP who could put some light on this issue?

Sharon

"JLGWhiz" wrote:

I have noticed similar behavior when debugging. Although I could not
immediately see a reason, I have come to believe that it is a logic protocol
built into VBA that, in certain circumstances, VBA will check to see if there
is another part of the code that needs to do things like recalculate, run a
before event code, etc. It is the only explanation I could come up with.

"sharon" wrote:

I see a weird behaviour in VBA code, not always but from time to time.
I've seen this in more than one workbook, so I'd like to know how to fix it.

Having (line numbers are just for explanation purposes)
001 For each cel in range("rTotal")
002 cel.offset(0,2)="x"
003 Next
....
....
100 Function anYthing( xLOL as string) as string
101 Application.Volatile True
102 Sheets("STAT").Select
103 Range("lVAL").Select
104 Sw = Sw + 1
105 If Sw 250 Then
106 MsgBox ("Times: " + Str(Sw))
107 End If
108 anYthing="anything"
109 Function End


While normal flow would be looping through steps 1 -2 -3 some times I can
see (while debugging) that flow is 1 - 2 - and looping (several times) steps
103 104 - 100, which is a function actually not invoked.
Eventually it goes back to 3-2-1

Any clue?

Sharon

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Weird Behaviour Function not invoked

So far, is any MVP or regular user who could put some light on this issue?

A simple strX=Cel causes a weird jump to the un-invoked Function, doing just
3 steps on it (several times) and exiting after doing a sentence like
Range("F2").Select when there are 50 sentences after this one and before the
End Function

????

TIA,

Sharon


"JLGWhiz" wrote:

I have noticed similar behavior when debugging. Although I could not
immediately see a reason, I have come to believe that it is a logic protocol
built into VBA that, in certain circumstances, VBA will check to see if there
is another part of the code that needs to do things like recalculate, run a
before event code, etc. It is the only explanation I could come up with.

"sharon" wrote:

I see a weird behaviour in VBA code, not always but from time to time.
I've seen this in more than one workbook, so I'd like to know how to fix it.

Having (line numbers are just for explanation purposes)
001 For each cel in range("rTotal")
002 cel.offset(0,2)="x"
003 Next
....
....
100 Function anYthing( xLOL as string) as string
101 Application.Volatile True
102 Sheets("STAT").Select
103 Range("lVAL").Select
104 Sw = Sw + 1
105 If Sw 250 Then
106 MsgBox ("Times: " + Str(Sw))
107 End If
108 anYthing="anything"
109 Function End


While normal flow would be looping through steps 1 -2 -3 some times I can
see (while debugging) that flow is 1 - 2 - and looping (several times) steps
103 104 - 100, which is a function actually not invoked.
Eventually it goes back to 3-2-1

Any clue?

Sharon

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird VBA Behaviour msnyc07 Excel Worksheet Functions 13 February 15th 10 08:04 AM
Weird WindowsMediaPlayer behaviour teepee[_3_] Excel Discussion (Misc queries) 1 October 26th 08 11:20 PM
weird behaviour from combo box medic Excel Programming 2 June 6th 08 07:02 AM
Weird Behaviour of Code Carlo Excel Programming 11 November 9th 06 11:55 AM
Weird Cell Behaviour Matt[_33_] Excel Programming 14 October 18th 05 06:42 PM


All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"