0

This is probably a quick fix, but I am new to VBA and I'm somewhat confused. I have a module:

Function classify (r As Range)
Debug.Print("Text")
End Function

Function foo(r As Range)
Debug.Print(r.Count)
End Function

There is working code before and after the module.

If, in a cell in excel, I write =foo(A1) and then press enter, I get the following output:

 1 
Text

Why? How did foo call classify? Moreover, if I just call '=classify(A1)', I get

Text
Text

Has classify somehow been set to always get called? Any help is greatly appreciated

4

1 回答 1

5

The only way that I could reproduce your issue was with the following scenario:

Cell A1:
=foo(A1)

Cell A2:
=classify(A1)

When updating cell A1 I get

1
Text

I think this is due to the fact that Cell A2 has a reference to A1 so by updating A1 I also call the formula in A2 as it is referencing A1.

Assuming your formula that you are entering is in A1 I would trace dependents to see where the other formula is.

于 2012-12-12T23:35:52.890 回答