LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Macro Unexpectedly calls a Function

I can't figure this problem out and am getting quite frustrated and hope that
someone can HELP, PLEASE!!

My environment is: Windows XP Version 2002 Service Pack 2 and MS Office
Excel 2003 SP2. My workbook has three worksheets with many hyperlinks in
each worksheet.

I developed a user defined function (UDF) that exists in only the last
worksheet. The purpose of the UDF counts the cells within the last worksheet
based on the fill color. I wrote another program (ListHyplinks) to list the
hyperlinks within each worksheet. It cycles through each worksheet and lists
the hyperlinks in a Hyperlinks worksheet.

Here is the UDF function line, which is stored in a module named: ContColr.

Function CntClr(InRange As Range, ColorIndex As Long, Optional OfText As
Boolean = False) As Long

Here is part of the Hyperlink list program, which is stored in a module
named: Module2

Sub ListHyplinks()
Option Explicit
(((( There are various declaration statements that go here ))))
totwksnbr = Worksheets.Count
wrbkname = ActiveWorkbook.Name
Firstwks = True
icnt = 1

Cycle through each worksheet
For wksnbr = 1 To totwksnbr
curwksname = Worksheet(wksnbr).Name
Answer = Msgbox(curwksname & is the current worksheet. _
& vbCr & vbCr & Do you want to list the links?, vbYesNo, List
Hyperlinks)

If Answer = vbYes Then
If(Firstwks) Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Na me = Hyperlinks
Firstwks = False
Call WriteHeading
For Each h In ActiveSheet.Hyperlinks
Cells(icnt, 1) = h.address
icnt = icnt + 1
Next
(((( Additional statements go here ))))

When I run the ListHyplinks program control jumps to Function CntClr after
creating the "Hyperlinks" worksheet in the "If (Firstwks)" statement. It
cycles through that function for a bit and then returns. Then upon executing
the "Cells(icnt, 1) = h.address" statement control once jumps to the
Function CntClr again, cycles through and returns.

To investigate this phenomenon I performed the following debug process:

Scenario 1: Set debug breakpoint @ "If Answer = vbYes"
Ran the ListHyplinks program
Step to the "If (Firstwks) statement
"Hyperlinks" worksheet is created
Unexpectedly control then jumps to Function CntClr
I stop the program

Scenario 2: After completing Scenario 1
"Hyperlinks" worksheet still exists and is cleared out
I comment out the "If (Firstwks)" statement
Re-ran the ListHyplinks program using the same debug
breakpoint
Step through the program
Once it reaches "Cells(icnt, 1) = h.address" control jumps
to Function CntClr
I stop the program

Scenario 3: After completing Scenario 2
"Hyperlinks" worksheet still exists and is cleared out
Re-ran the ListHyplinks program using the same debug
breakpoint
The program runs as intended without control jumping to
Function CntClr????

Any assistance in resolving this issue would be greatly appreciated. Thank
you in advance for your time and efforts.

Steve


 
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
Macro unexpectedly jumps to other macros and functions Options MarkM[_5_] Excel Programming 1 December 7th 07 03:24 AM
Using ODBC function calls Dave[_64_] Excel Programming 0 February 15th 06 02:37 PM
VBA: How to pass arrays in Function Calls? Mac Lingo[_2_] Excel Programming 4 November 1st 05 06:26 PM
Macro unexpectedly jumps to other macros and functions Jeff Wright[_2_] Excel Programming 3 November 25th 04 01:47 PM
function calls Claude Excel Programming 2 December 5th 03 01:55 PM


All times are GMT +1. The time now is 04:45 AM.

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"