ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Software

Free Microsoft Excel Math Factoring Software Tool (VBA, Visual Basic, VB)

Updated on June 23, 2012

This hub provides a program which prompts for a number, then solves for all its whole number factors. For example, entry of “8” will return 8,1 and 4,2. Numbers with many more factors can be entered, i.e. 50, 512, 1024, 10,000 …etc. All that is needed is Microsoft Excel, and programming code I will provide here. Open up Excel. We will need the “Developer” tab. In order to make it visible, do as follows:

File --> Options (click), Customize Ribbon (click), Check the “Developer” box and click “OK” at bottom. “Developer” tab is now visible. Click it, and a section dealing with macros and VBA (Visual Basic) can now be seen at far left.

We will create a blank macro (program), and paste some code in. On the left, click the tab “Record Macro”. A box pops up. It has been given a name, “Macro1”. Leave it as is. There will also be a shortcut key entry, make it “ctrl a”. Click OK. Where tab at upper left now says “stop recording”, click it. Click the “Macros” tab and the blank macro just created will pop up. Referring to the picture in this hub, place the blinking cursor as shown with arrow keys: first use arrow keys to place the cursor at immediate left side (beginning) of “End Sub”. Hit down arrow 5 times to move “End Sub” down. Move cursor up by hitting up arrow key 2 times. Then copy/paste in this code:

Application.EnableCancelKey = xlDisabled

Dim x As Single, y As Single, acell As String, xstr As String

On Error GoTo eh




ActiveCell.Value = "Factors"

ActiveCell.Offset(1, 0).Select

acell = ActiveCell.Address

x = InputBox("Enter the whole number you wish to determine factors for (integer or whole number factors only).")

y = 1


If x / (x / y) > x / y Then Exit Do

If x / y = Int(x / y) Then

ActiveCell.Value = x / y & " , " & x / (x / y)

ActiveCell.Offset(1, 0).Select

acell = ActiveCell.Address


End If

y = y + 1



Range(Selection, Selection.End(xlDown)).Select


ActiveWindow.Zoom = True


Exit Sub


MsgBox ("Data entry error. Try again.")

Close the program box and re-save the Excel workbook, keeping it open. Hit “ctrl a” and the program will run.


    0 of 8192 characters used
    Post Comment

    No comments yet.