Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default note/coinage converter???

On Wednesday, June 7, 2000 3:00:00 AM UTC-4, Chip Pearson wrote:
Sheila,

Here's a simple VBA function that will return an array of 10 items. The
elements of the array indicate the number of bills and or coins to make the
input amount.

It returns the counts for $100 bills, $50, $20, $10, $5, $1, quarters,
dimes, nickels, and pennies, so the array has 10 elements. To use it in a
worksheet, select a range of 10 cells, e.g., D2:M2, type
=ConvertToCurrency(A2) and press Ctrl+Shift+Enter. Because the function
returns an array, you *must* press Ctrl+Shift+Enter rather than just Enter
when you first enter the formula and whenever you edit it later.

Function ConvertToCurrency(ByVal Amt As Double) As Variant
Dim Ndx As Integer
Dim Counter As Integer
Dim Arr As Variant
Arr = Array(100, 50, 20, 10, 5, 1, 0.25, 0.1, 0.5, 0.01)
For Ndx = LBound(Arr) To UBound(Arr)
Counter = 0
While (Amt + 0.0001) = Arr(Ndx)
Counter = Counter + 1
Amt = Amt - Arr(Ndx)
Wend
Arr(Ndx) = Counter
Next Ndx
ConvertToCurrency = Arr
End Function

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting Services
www.cpearson.com




Hi Chip,

I've found this VBA function to be very helpful despite my being totally new to macros.
However, my currency also includes a $2 note and issuing of the 1 cent coin has been discontinued. How can the VBA function be modified to adapt to these changes?

Thanks much!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Like a note but it's not-What is it? Gary S[_2_] Excel Discussion (Misc queries) 4 July 31st 09 02:13 PM
coinage M-H Excel Discussion (Misc queries) 1 May 28th 09 08:20 PM
Notes and Coinage for Wages Owl Excel Worksheet Functions 3 August 2nd 08 12:53 AM
Validation note to comment note Oldjay Excel Discussion (Misc queries) 1 August 23rd 07 04:27 PM
Note to Bob Phillips Steph[_3_] Excel Programming 1 August 12th 04 08:51 PM


All times are GMT +1. The time now is 12:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"