Using VBA to add digits togeather

mchad

New Member
Joined
Jun 29, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to create a function that will let me input a number, and the function will do the following:
  1. Add the digits in that number togeather
  2. Check if the resulting sum is a single digit (1-9), 11, or 22;
  3. Return the number if the #2 is true
  4. Start Back at #1 with the new number if #2 is false .
The number of digits will fluxuate. I have been trying to use an array nut I have been having trouble splitting the number into the array effectively.
 
I would be careful with using Integer as parameter type in this case, if your number is likely to increase in length?
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,215,506
Messages
6,125,194
Members
449,214
Latest member
mr_ordinaryboy

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