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
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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
 
Upvote 0
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
 
Upvote 0
Gene

Do you have Analysis Toolpak - VBA installed?
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,851
Messages
6,121,931
Members
449,056
Latest member
denissimo

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