248円の場合は100円玉2枚,10円玉4枚,5円玉1枚,1円玉3枚というように、金額からお札と硬貨の枚数をエクセルで計算したいときがありますよね。
残念ながらエクセルの標準関数には金額からお札と硬貨の枚数を計算する数式がありません。
そこで、エクセルでもお札と硬貨の枚数を計算できるプログラムを作成しましたので、ファイルのダウンロード、もしくはコードをコピーして利用して頂ければ思います。
※2000円札は現在実質使用されていないので、2000円札は使用しない前提でプログラムを作成しています。
目次
ファイルのダウンロード
お札と硬貨の枚数を計算できるエクセルファイルはこちらからダウンロードできます。ファイルを利用する方はファイルを開いて「コンテンツの有効化」をクリックしてください。
使い方
エクセルの標準関数を利用するのと同様の方法で、関数名の引数に計算したいセルを入力します。
計算する関数名は「money+金額」としました。
=money10000(セル名) '10000円の枚数を計算 =money5000(セル名) '5000円の枚数を計算 =money1000(セル名) '1000円の枚数を計算 =money500(セル名) '500円の枚数を計算 =money100(セル名) '100円の枚数を計算 =money50(セル名) '50円の枚数を計算 =money10(セル名) '10円の枚数を計算 =money5(セル名) '5円の枚数を計算 =money1(セル名) '1円の枚数を計算
実際の使用例は下記のようになります。
コードをコピーする場合
コードをコピーして使用する場合は、以下の手順になります。
「開発」からVBEを起動
ファイルから標準モジュールを選択
下記画面のようにコードを貼り付ける。
貼り付けるコードは下記になります。
Function money10000(x As Long) As Integer money10000 = x \ 10000 End Function Function money5000(x As Long) As Integer money5000 = (x Mod 10000) \ 5000 End Function Function money1000(x As Long) As Integer money1000 = (x Mod 5000) \ 1000 End Function Function money500(x As Long) As Integer money500 = (x Mod 1000) \ 500 End Function Function money100(x As Long) As Integer money100 = (x Mod 500) \ 100 End Function Function money50(x As Long) As Integer money50 = (x Mod 100) \ 50 End Function Function money10(x As Long) As Integer money10 = (x Mod 50) \ 10 End Function Function money5(x As Long) As Integer money5 = (x Mod 10) \ 5 End Function Function money1(x As Long) As Integer money1 = x Mod 5 End Function
コメント