GCF in a VBA macro

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
There is no VBA function for the GCF of two numbers and when I try to use application.worksheetfunction.gcf (or gcd) I get the error that object is not supported. Is the only way out to write my own GCD function?

Gene, "The Mortgage Man", Klein
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
GCD is part of the Analysis ToolPak. To use it in VBA install the Add-In "Analysis ToolPak - VBA", then click your workbook in the VBE and set a reference to atpvbaen.xls (Tools|References). Sample code:

Code:
Sub Test()
    MsgBox GCD(24, 36)
End Sub
 

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
GCD is part of the Analysis ToolPak. To use it in VBA install the Add-In "Analysis ToolPak - VBA", then click your workbook in the VBE and set a reference to atpvbaen.xls (Tools|References).




When looked for atpvbaen.xls in the list it wasn't there - and I have the Analysis ToolPak installed. I used Seti's link to get a UDF, but I would like to be able to use other toolpak's functions in VBA. Any ideas why it didn't show up?

Gene, "The Mortgage Man", Klein


Sub Test()
MsgBox GCD(24, 36)
End Sub
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,288
Gene

Do you have Analysis Toolpak - VBA installed?
 

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
Gene

Do you have Analysis Toolpak - VBA installed?
_________________
What happened to my stuff?
Nope - that was it. I didn't realize there were two separate "things" to install. Now that I have it - is there any way to get a list of all the new goodies that I have available to me?

Gene, "The Mortgage Man", Klein
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,288
Gene

Open the Object Browser (F2), and select atpvbaen.xls from the first dropdown.

In the classes pane select VBA Functions and Subs.

You should now have a list of functions in the Members pane.

If you click any of them you'll get the syntax and a (very short) description displayed in the bottom pane.
 

Forum statistics

Threads
1,078,373
Messages
5,339,814
Members
399,330
Latest member
mallikharjun

Some videos you may like

This Week's Hot Topics

Top