Two UDF's in a single cell

Giordano Bruno

Well-known Member
Joined
Jan 7, 2007
Messages
1,356
This seems to me to be an Excel Bug. I am using Excel 365 and in a workbook I create the following UDF
Function Multiply(x As Double)
x = x * 2
Multiply = x
End Function
This work perfectly in the form "=Multiply(A1)" and also as "=Multiply(A1)+Multiply(A1)"
The moment I use the second formula, (a) breakpoints in my Worksheet_Change code (and any other code for that matter) cease to work, (b) I cannot step through any code in any module of any worksheet. Removing the formula does not undo the damage. Closing Excel and restarting does. I have tried this on two computers. Has anyone else noticed this problem? Does anyone have a workaround?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hmm, I'm on 365 and it works fine for me !!!
Have you tried
Excel Formula:
=Multiply(A1)*2
 
Upvote 0
Hi Michael,
I'm not sure I've made myself clear. This is not a trivialo thing. "=Multiply(A1)+Multiply(A1)" works as it should. The problem is its effect upon vba. Once vba has dealt with the two UDF's in a single cell, break points stop working and stepping through the code doesn't work, and the damage persists until Excel is closed and reopened. I originally discovered this problem with more complex UDF's, but I have tried to rule out all extransous issues with the simplest possible UDF.
Can I ask you to test the effect by putting a break point in the function and testing whether the code stops or ignores it.
 
Upvote 0
Try renaming the function from Multiply to a generic term....GB for instance.
 
Upvote 0
Thank you Michael. Have you tried it yourself? Have you tested the effect on VBA afterwards? I have tested this on numerous functions. The Multiply function is simply the most basic and easy to test. The name of the function is not relevant. You can put two UDF's in a single cell and they work fine. That's not the issue. The problem is the effect it has on vba code.
 
Upvote 0
Yep, created a Sub in "This Workbook" module, and after running the Multiply function the other Sub runs fine, including break point.
Sounds like your Workbook might have got corrupyed.
 
Upvote 0
I can confirm that it worked for me too with a breakpoint in the udf and one in the worksheet change event.
 
Upvote 0
Many thanks for testing that Michael and thanks Alex for your confirmation. The curious thing is that I've tried it on two computers with the same result on both. With only a single UDF the break points work, but as soon as I add the second UDF, the code runs over the break points. Both computers are running Windows 10 and Excel 365. I've hauled out an antique Toshiba running Excel 2010 and that one doesn't have a problem. Any suggestions why I'm having this experience on both of my Excel 365 computers. Any suggestions for a workaround?
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,111
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top