LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Function behaviour, can someone explain please?


Without being able to see your other code I can not tell you why this
would be called unexpectedly. Try making the switch to private (if
this function is ont intended to be called outside of this sheet or
modue) and let me know how it goes.

HTH...



Hi Jim,

Thanks for that.

I tried going 'private' with the function, which was in it's own module
with nothing else.

I then tried to run this code from a different module in the same
workbook...

Sub CopyCols()
Range("f2:h21").Select
Selection.Copy
Sheets("WEB QUERY").Select
Range("k2").Select
Selection.PasteSpecial paste:=xlPasteValuesAndNumberFormats
End Sub

The function was called at the Selection.PasteSpecial line.

Again the function looped seemingly infinitely, so I put in a counter in
the function and added the two extra lines to the above code...

Sub CopyCols()
testcount = 0
Range("f2:h21").Select
Selection.Copy
Sheets("WEB QUERY").Select
Range("k2").Select
Selection.PasteSpecial paste:=xlPasteValuesAndNumberFormats
MsgBox "there were " & testcount & " loops this time"
End Sub

On running this code again and again I got 467 loops then 263 loops and
then curiously got zero loops time after time.

I'm trying to reproduce the loops to see if I can pin down what triggers
the calling but am unable to at the minute.

I'll post on here if I come up with any sort of answer.

Is it possible to put the function code in the worksheet module to where it
pertains, so that it doesn't stray outside? Maybe on a Worksheet_Change
event?

Ron
 
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
Please explain YIELDMAT function JoeU2004 Excel Worksheet Functions 9 September 10th 09 02:04 AM
Large function - Please explain Danny Excel Worksheet Functions 5 December 18th 07 08:34 PM
Please explain function/formula Tara H Excel Worksheet Functions 6 July 24th 06 07:16 PM
Custom Function behaviour? Ron[_28_] Excel Programming 7 December 30th 04 11:10 PM
Behaviour of VBA ROUND function Microsoft Forum Excel Programming 3 December 30th 04 04:16 PM


All times are GMT +1. The time now is 06:18 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"