VBA excel help please

emmcee

New Member
Joined
Sep 9, 2011
Messages
29
Hello All,

I need help with a homework that I've been working on, which is writing a code to find the factorial of a value where the constant include:

Const COL_N = 1 ' column for the n values
Const COL_NFACT = 2 ' column for the factorial values
Const ROW_START = 2 ' ignore header row

calculate factorials (n! = 1 * 2 * 3 * ... * (n–1) * n) using VBA and display them on a spreadsheet .


I have to create a subprogram that contains a loop that generates factorials in order, starting with 0! = 1, 1! = 1*0! = 1, 2! = 2*1! = 2, 3! = 3*2! = 6 and so on.

Notice that each step uses the next value of n and the previous factorial value to produce the next.



Given variables holding the row and column numbers, I have to assign a cell using one of these statements:


ActiveSheet.Cells(row, col).Value = myData

ActiveSheet.Cells(row, col) = myData

Some way of stopping the generation process. For this version there is a cell on the sheet named MaxFact. Pick up this value using the ActiveSheet.Range(name) notation, where name is a string constant or variable holding the name or address of the required cell. Stop the iteration when the factorial exceeds this value, but before displaying it (the algorithm structure should allow this).

Also if you are able to use the While structure to express this condition.

Thanks in Advance!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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