注目の投稿

今まで作成したエクセルツールまとめ

2018/02/28

Excel tool KWR (SOUTH KOREAN WON) version for cryptocurrency price and market cap -Using Excel VBA

I am happy to announce the release of Excel tool for cryptocurrency price and market cap.
I have developed KRW (SOUTH KOREAN WON) version. Please access link below.

Download : My_CryptocurrencyMarketCap_Data_List_KRW1.xlsm (in Google drive)

I have updated this Excel macro tool. Please access link below.
Excel macro tool to get cryptocurrency market cap price data -Using Excel VBA


This tool can fetch cryptocurrency details once you click on the command button in the Sheet.
By using the API, it display the data read from Cryptocurrency Market Capitalizations. Currency unit is displayed in KRW (SOUTH KOREAN WON) .

Remember to enable macros to Excel. Otherwise this Excel tool will not work.



・Operation procedure
Enter arbitrary cryptocurrency symble in the cell after the third row of column A as shown below, and click GO button. It is displayed in a few seconds to tens of seconds
When you press the All Symbol button, you will see the symbols of all the coins with more than 1000 in Cryptocurrency Market Capitalizations.

Each data is displayed as shown below.
Pressing the Clear button erases the values and formatting of all cells below the third row. The symbol also disappears.

Notice: If the Excel tool freezes, please open task manager by pressing Ctrl + Shift + Esc and Forcibly terminate it.

In personal experience, macro stopped in Http.send of program. One day, It was fixed unexpectedly. I am not sure the reason, although I tried to repair it a lot.




Donate BTC: 1LcULwCQPjxLGXdpEJkhNkPpqCwG5csasU

Donate LTC: LSXEG7tjeCCGWuzvf5eFvJUZM6Xpvsdc4f






2018/02/27

Excel tool INR (Indian rupee) version for cryptocurrency price and market cap -Using Excel VBA

I am happy to announce the release of Excel tool for cryptocurrency price and market cap.
I have developed INR (Indian rupee) version. Please access link below.

Download : My_CryptocurrencyMarketCap_Data_List_INR1.xlsm (in Goolge drive)

I have updated this Excel macro tool. Please access link below.
Excel macro tool to get cryptocurrency market cap price data -Using Excel VBA


This tool can fetch cryptocurrency details once you click on the command button in the Sheet.
By using the API, it display the data read from Cryptocurrency Market Capitalizations. Currency unit is displayed in INR (Indian rupee).

Remember to enable macros to Excel. Otherwise this Excel tool will not work.



・Operation procedure
Enter arbitrary cryptocurrency symble in the cell after the third row of column A as shown below, and click GO button. It is displayed in a few seconds to tens of seconds
When you press the All Symbol button, you will see the symbols of all the coins with more than 1000 in Cryptocurrency Market Capitalizations.

Each data is displayed as shown below.
Pressing the Clear button erases the values and formatting of all cells below the third row. The symbol also disappears.

Notice: If the Excel tool freezes, please open task manager by pressing Ctrl + Shift + Esc and Forcibly terminate it.

In personal experience, macro stopped in Http.send of program. One day, It was fixed unexpectedly. I am not sure the reason, although I tried to repair it a lot.



Donate BTC: 1LcULwCQPjxLGXdpEJkhNkPpqCwG5csasU
Donate LTC: LSXEG7tjeCCGWuzvf5eFvJUZM6Xpvsdc4f







Excel tool AUD version for cryptocurrency price and market cap -Using Excel VBA

I am happy to announce the release of Excel tool for cryptocurrency price and market cap.
I have developed AUD (Australian dollar) version. Please access link below.

Download : My_CryptocurrencyMarketCap_Data_List_AUD1.xlsm (in Google drive)

I have updated this Excel macro tool. Please access link below.
Excel macro tool to get cryptocurrency market cap price data -Using Excel VBA


This tool can fetch cryptocurrency details once you click on the command button in the Sheet.
By using the API, it display the data read from Cryptocurrency Market Capitalizations. Currency unit is displayed in AUD.

Remember to enable macros to Excel. Otherwise this Excel tool will not work.



・Operation procedure
Enter arbitrary cryptocurrency symble in the cell after the third row of column A as shown below, and click GO button. It is displayed in a few seconds to tens of seconds
When you press the All Symbol button, you will see the symbols of all the coins with more than 1000 in Cryptocurrency Market Capitalizations.

Each data is displayed as shown below.
Pressing the Clear button erases the values and formatting of all cells below the third row. The symbol also disappears.

Notice: If the Excel tool freezes, please open task manager by pressing Ctrl + Shift + Esc and Forcibly terminate it.

In personal experience, macro stopped in Http.send of program. One day, It was fixed unexpectedly. I am not sure the reason, although I tried to repair it a lot.


Donate BTC: 1LcULwCQPjxLGXdpEJkhNkPpqCwG5csasU
Donate LTC: LSXEG7tjeCCGWuzvf5eFvJUZM6Xpvsdc4f




ブログからgoogleドライブ経由でエクセルをダウンロードできるようにする方法 -blogger

ブログからgoogleドライブを使用してExcelをダウンロードできるようにする方法をお伝えします。

1.googleドライブにエクセルファイルをアップロードします。ドラッグ&ドロップでできます。

2.アップロードしたエクセルのアイコンを右クリック→共有可能なリンクを取得をクリック

3.リンクの共有がONになっているのを確認して、リンクのアドレスをコピーします。

4.アドレスをブログにペーストします。

これでアドレスのリンクからgoogleドライブ上のエクセルファイルにアクセスしてダウンロードできます。




用於加密貨幣的Excel宏TWD版本 Excel tool TWD version for cryptocurrency price and market cap

我很高興地宣布發行用於加密貨幣價格和市值的Excel。

我開發了TWD(新台幣)版本。 請訪問下面的鏈接。

Download : My_CryptocurrencyMarketCap_Data_List_TWD1.xlsm (in Google drive)

This tool can fetch cryptocurrency details once you click on the command button in the Sheet.
By using the API, it display the data read from Cryptocurrency Market Capitalizations. It displays in TWD.

Remember to enable macros to Excel. Otherwise this Excel tool will not work.



・Operation procedure
Enter arbitrary cryptocurrency symble in the cell after the third row of column A as shown below, and click GO button. It is displayed in a few seconds to tens of seconds
When you press the All Symbol button, you will see the symbols of all the coins with more than 1000 in Cryptocurrency Market Capitalizations.

Each data is displayed as shown below.
Pressing the Clear button erases the values and formatting of all cells below the third row. The symbol also disappears.

Notice: If the Excel tool freezes, please open task manager by pressing Ctrl + Shift + Esc and Forcibly terminate it.

In personal experience, macro stopped in Http.send of program. One day, It was fixed unexpectedly. I am not sure the reason, although I tried to repair it a lot.


Donate BTC: 1LcULwCQPjxLGXdpEJkhNkPpqCwG5csasU

Donate LTC: LSXEG7tjeCCGWuzvf5eFvJUZM6Xpvsdc4f

Excel tool GBP (STG) version for cryptocurrency price and market cap -Using Excel VBA

I am happy to announce the release of Excel tool for cryptocurrency price and market cap.
I have developed GBP (Great Britain Pound) version. Please access link below.

Download : My_CryptocurrencyMarketCap_Data_List_GBP1.xlsm (in Google drive)

I have updated this Excel macro tool. Please access link below.
Excel macro tool to get cryptocurrency market cap price data -Using Excel VBA



This tool can fetch cryptocurrency details once you click on the command button in the Sheet.
By using the API, it display the data read from Cryptocurrency Market Capitalizations. It displays in GBP.

Remember to enable macros to Excel. Otherwise this Excel tool will not work.



・Operation procedure
Enter arbitrary cryptocurrency symble in the cell after the third row of column A as shown below, and click GO button. It is displayed in a few seconds to tens of seconds
When you press the All Symbol button, you will see the symbols of all the coins with more than 1000 in Cryptocurrency Market Capitalizations.

Each data is displayed as shown below.
Pressing the Clear button erases the values and formatting of all cells below the third row. The symbol also disappears.

Notice: If the Excel tool freezes, please open task manager by pressing Ctrl + Shift + Esc and Forcibly terminate it.

In personal experience, macro stopped in Http.send of program. One day, It was fixed unexpectedly. I am not sure the reason, although I tried to repair it a lot.


Donate BTC: 1LcULwCQPjxLGXdpEJkhNkPpqCwG5csasU
Donate LTC: LSXEG7tjeCCGWuzvf5eFvJUZM6Xpvsdc4f




2018/02/26

Excel tool EUR version for cryptocurrency price and market cap -Using Excel VBA

I am happy to announce the release of Excel tool for cryptocurrency price and market cap.
I have developed EUR version. Please access link below.

Download : My_CryptocurrencyMarketCap_Data_List_USDEUR1.xlsm in Google Drive

I have updated this Excel macro tool. Please access link below.
Excel macro tool to get cryptocurrency market cap price data -Using Excel VBA


This tool can fetch cryptocurrency details once you click on the command button in the Sheet.

Remember to enable macros to Excel. Otherwise this Excel tool will not work.



・Operation procedure
Enter arbitrary cryptocurrency symble in cell, and click GO button. It is displayed in a few seconds to tens of seconds

Each data is displayed.

Notice: If the Excel tool freezes, please open task manager by pressing Ctrl + Shift + Esc and Forcibly terminate it.

In personal experience, macro stopped in Http.send of program. One day, It was fixed. I am not sure the reason, although I tried to repair it a lot.


Donate BTC: 1LcULwCQPjxLGXdpEJkhNkPpqCwG5csasU
Donate LTC: LSXEG7tjeCCGWuzvf5eFvJUZM6Xpvsdc4f







2018/02/25

仮想通貨の価格や時価総額のデータを表示するエクセルツール(無料、ダウンロード可) -Excel VBA

仮想通貨のデータを表示するExcel のマクロツールを公開したいと思います。

APIを利用してCryptocurrency Market Capitalizationsから読み込んだデータを表示します。

価格はドル建て、円建て、btc建ての3種類を表示します。その他に時価総額のランキング順位、時価総額、24時間の出来高、1時間・24時間・7日間の変動率を表示します。

任意の仮想通貨のシンボル(BTC, ETHなど)をA列に入力するとそのシンボルだけのデータが表示されるようになっています。



☆ダウンロードはこちら (無料)

My_CryptocurrencyMarketCap_Data_List_1.xlsm (Googleドライブ上)



ダウンロードした後

1.下のリンクからVBA-JSONのZipファイルをダウンロードします。
 https://github.com/VBA-tools/VBA-JSON/releases


2.ダウンロードしたエクセルファイルを開く。エクセルのVBEを開く(ショートカット:Alt+F11)。ファイル→ファイルのインポートを選択してダウンロードしたZipファイルの中にある、JsonConverter.basというファイルを選択する。※

※ファイルのインポートからZipファイルを選択してエラーが出たら、Zipファイルから「VBA-JSON-2.2.3」のフォルダをデスクトップなどどこでもいいので外に出して、ファイルのインポートから「VBA-JSON-2.2.3」のフォルダを選択してその中のJsonConverter.basというファイルを選択する。

3.VBEのツールタブの参照設定からMicrosoft Scripting Runtimeにチェックを入れる。

エクセルファイルのプロパティの作成者、前回保存者を消す方法 -Excel

Excelのプロパティの作成者、前回保存者を消す方法についてお伝えします。

・方法1
ファイル→ブックの検査→ドキュメントのプロパティと個人情報にチェック入れる→検査

これをやるとプロパティの情報を削除できるのですが、ファイル保存時に『ドキュメント検査機能では削除できない個人情報がドキュメントに含まれていることがありますので、ご注意ください。』とメッセージが表示されてしまいます。

私はこの表示を出したくなかったので他の方法を探しました。

・方法2
デスクトップのエクセルのアイコン右クリック→プロパティ→詳細タブ→下のほうにあるプロパティや個人情報を削除をクリック→このファイルから次のプロパティを削除を選択、前回保存者にチェックを入れる→OK

この方法ならメッセージも出ることなく前回保存者を削除できました。




2018/02/23

仮想通貨の散布図 -Excel VBA

CryptoCurrency market capのAPIを利用して仮想通貨約1100銘柄の散布図をExcel VBAで出してみました。全部で1547位までありますが、market cap と24h volumeの両方のデータをとれる銘柄が約1100となります。

一番右上がBTCです。意外に感じましたがUSDTが24h volumeでは2位でした。






2018/02/21

マイナスの数値を赤字にする方法 -Excel VBA

エクセルの表でマイナスの数値を赤字にする方法をお伝えします。

Dim rng As Range
    For Each r In Range("I2:M30")
        If rng.Value < 0 Then
            rng.Font.Color = RGB(255, 0, 0) ’赤色
        End If
    Next

このように範囲rng内の0より低い値を赤色にするようプログラムします。

・マイナスが黒字の場合

・マイナスを赤字に変更







2018/02/18

セルの座標を表示 Excel VBA

Excel VBAではグラフや図を入れる時や移動する時に座標を使う時があります。

下記のコードを使えばセルの位置に合わせたTopとLeftの座標をメッセージボックスで表示できます。

Sub coordinate1()

Dim rng1 As Range
Set rng1 = Range("A1")

MsgBox rng1.Top & vbLf & rng1.Left
End Sub







エクセルのウインドウを画面の右半分、左半分に移動する方法 -Excel 2013 Windows10

私がエクセルのウインドウを画面の右半分か左半分に移動した方法をお伝えします。
筆者環境:Excel 2013、 Windows10

・ショートカットキー
Windowsキー + ← or →

これでウインドウが移動しない場合は、

コントロールパネル→コンピューターの簡単操作→キーボードの動作の変更→「ウインドウが画面の端に移動されたときに自動的に整列されないようにします」のチェックを外す。


この後ショートカットキー「Windowsキー + ← or → 」で私の場合は解決しました。




プログラム修正 Excelで仮想通貨の資産管理6-2 -Excel VBA

前回は各銘柄の損益額の割合を出して損益率の棒グラフを表示しました。マクロの登録で生成されるプログラムをそのまま使用している箇所があり見にくかったりわかりづらさがありました。
それを修正するため、自分なりに読みやすいコードを考えてみました。

前回の記事はこちら

コード

'bar chart
    Dim bar1 As ChartObject
    
    Set bar1 = Sheet1.ChartObjects.Add(500, 150, 200, 100)
    
 ' chart range
    Set rng = Range(Cells(2, 2), Cells(trow - 1, 2))  ’B列
    Set rng = Union(rng, Range(Cells(2, 10), Cells(trow - 1, 10)))  ’J列
    
    With bar1
         .name = "Graph 2"
         .Height = 200
         .Width = 400
    End With
    
    'chart type title, style
    With bar1.Chart
         .SetSourceData Source:=rng
         .ChartType = xlColumnClustered
         
         .HasTitle = False

         .ApplyLayout (11)  ’レイアウト表示
         .SetElement (msoElementDataLabelOutSideEnd)  ’データ ラベルを外側の末尾に表示
         .ChartColor = 13
    End With

●実行結果




bitFlyer ビットコインを始めるなら安心・安全な取引所で

プログラム修正 Excelで仮想通貨の資産管理4-2 -Excel VBA

Excelで仮想通貨の資産管理4 -Excel VBAで円グラフを表示させました。マクロの登録でそのまま出てくるShapes.AddChart2メソッドを使用していました。

よりわかりやすいコードを記述するために、マクロそのままではなく今回はchartobjectオブジェクトを使用したいと思います。

・コード

  ' pie chart
    Dim pie1 As ChartObject
 
 ’グラフ追加()内はグラフのサイズ
    Set pie1 = Sheet1.ChartObjects.Add(150, 150, 200, 100)
     
    ' chart range
    Set rng = Range(Cells(2, 2), Cells(trow - 1, 2))
    Set rng = Union(rng, Range(Cells(2, 7), Cells(trow - 1, 7)))

 ’ChartObjectオブジェクトの操作
    With pie1
         .name = "Graph 1"
         .Height = 200
         .Width = 323.6
    End With

    ’Chartオブジェクトの操作
    With pie1.Chart
         .SetSourceData Source:=rng
         .ChartType = xlPie
       
         .HasTitle = True
         .ChartTitle.Text = "Allocation"

         .ClearToMatchStyle
         .ChartStyle = 251
         .ApplyLayout (1) ’円グラフから出てる線と文字のこと
       
    End With

実行結果
時間がない時はマクロをそのままコピーでもいいかもしれませんが、基本的には自分がしっかりと理解したプログラムを記述したいですね。

bitFlyer ビットコインを始めるなら安心・安全な取引所で


無料・ダウンロード可) 仮想通貨エクセルツール2 各国法定通貨換算可能!仮想通貨価格・時価総額データ表示アプリケーション -Excel VBA

参考サイト1
参考サイト2

2018/02/11

Excelで仮想通貨の資産管理5 -Excel VBA

前回までは任意の銘柄のデータと自分の資産額とその割合を表示しました。


今回は投資額と損益額を表示したいと思います。各銘柄分と総額で出したいと思います。

まずは、B列に銘柄のシンボルを入力、D列には保有通貨量を入力、G列には投資額(元本)を入力します。合計額は自動で出されるので入力不要です。その他の列は入力しなくてOKです。

コード
下記の赤字部分を変更しました。

back1:
    For Each CryptoCurrencyNode In CryptoCurrencyJSON
    If UCase(Cells(trow, 2)) = CryptoCurrencyNode(arr(2)) Then
    
        For i = 1 To 11
        
            If i <> 4 And i <> 7 And i <> 8 Then
             
            tickerSheet.Cells(trow, i) = CryptoCurrencyNode(arr(i))
            Else
               
            End If

        Next
        
       val_jpy = Cells(trow, 3) * Cells(trow, 4)
       tickerSheet.Cells(trow, 5) = Application.WorksheetFunction.RoundDown(val_jpy, 0)
       
       
       val_sum = Cells(trow, 5) + val_sum
       'profit and loss
       tickerSheet.Cells(trow, 8) = Cells(trow, 5) - Cells(trow, 7)
       ivm = Cells(trow, 7) + ivm
       pl = Cells(trow, 8) + pl
       trow = trow + 1
    GoTo back1:

    Else: End If
        
    Next
    
    'total, profit and loss
    tickerSheet.Cells(trow, 5) = val_sum
    tickerSheet.Cells(trow, 7) = ivm
    tickerSheet.Cells(trow, 8) = pl
    col = i
    
    For i = 2 To trow - 1
    tickerSheet.Cells(i, 6) = Cells(i, 5) / val_sum
    tickerSheet.Cells(i, 6).NumberFormatLocal = "0.0%"
        
    Next
    
    ●実行結果
G列に投資額、H列に損益額が表示されました。
bitFlyer ビットコインを始めるなら安心・安全な取引所で

2018/02/10

プログラム修正版)Excelで仮想通貨の資産管理 -Excel VBA

coinmarketcap.comのAPIを利用してExcelで仮想通貨の資産をまとめられるようにしています。今回はプログラムの修正の記事となります。


今まではB列に銘柄のシンボルをcoinmarketcapのランキング順に上のセルから入力して実行すると正常に表示されました。しかし、ランキングを無視して順番を入れ替えてセルにシンボルを入力すると空欄になってしまいその下の行も表示されませんでした。

・上からランキング順だと正常に表示。(C列にランキングを出しました。)

・ランキングの順番を入れ替えてLSKをXRPの上に入力して実行すると・・・

・LSKまでしか表示されず、その下は表示されない。


今回は銘柄の順番を入れ替えても正常に表示されるようにプログラムを修正しました

・コード
B列のセルに入力されたシンボルとAPIで読み込んだシンボルを照合してデータを表示するようにしています。修正前のプログラムでは、APIのデータを入れた配列は1位のBTCの照合が終わったあと下の行に移動し、2位のETHから照合していました。修正後は1位のBTCの照合が終わって下の行に移動したあとでもう一度1位のBTCから照合するようにしています。

   i = 0
    trow = 2
    val_sum = 0
back1:
    For Each CryptoCurrencyNode In CryptoCurrencyJSON
    If UCase(Cells(trow, 2)) = CryptoCurrencyNode(arr(2)) Then
 
        For i = 1 To 9
     
            If i <> 4 Then
           
            tickerSheet.Cells(trow, i) = CryptoCurrencyNode(arr(i))
            Else
             
            End If

        Next
     
       val_jpy = Cells(trow, 3) * Cells(trow, 4)
       tickerSheet.Cells(trow, 5) = Application.WorksheetFunction.RoundDown(val_jpy, 0)
     
       val_sum = Cells(trow, 5) + val_sum 
       trow = trow + 1
    GoTo back1:

    Else: End If
     
    Next
 
    tickerSheet.Cells(trow, 5) = val_sum
    col = i
 
    For i = 2 To trow - 1
    tickerSheet.Cells(i, 6) = Cells(i, 5) / val_sum
    tickerSheet.Cells(i, 6).NumberFormatLocal = "0.0%"
    Next

実行結果
LSKがXRPより上の行でも正常に表示されました。


いつも同じ通貨ばかり表示していてもどうかと思ったので通貨を変えた画像も載せておきます。こんな感じです。こちらもランキング順ではなく順番を入れ替えたものです。


無料・ダウンロード可) 仮想通貨エクセルツール2 各国法定通貨換算可能!仮想通貨価格・時価総額データ表示アプリケーション -Excel VBA

bitFlyer ビットコインを始めるなら安心・安全な取引所で

2018/02/08

コマンドボタンにマクロを登録する方法 Excel VBA

Excel VBAを使ってコマンドボタンにマクロを登録する方法をお伝えします。

まず開発タブをリボンに出すようにします。
ファイル→オプション→リボンのユーザー設定でメインタブの開発にチェックを入れてOKを押します。

次に、開発タブの挿入をクリックして、コマンドボタンを選択します。

するとカーソルが+マークになりますので任意のサイズにドラッグするとコマンドボタンが出現します。

コマンドボタン上でダブルクリックするとVBEのウインドウがでます。

Private Sub CommandButton1_Click()

End Sub

と、出てきますので間にCall +subプロシージャを記述します。下記のように記述します。

Private Sub CommandButton1_Click()
Call Crypto_JSON_In_Excel
End Sub

そしてコマンドボタンを押すと記述したsubプロシージャが実行されます。
ボタンを押せない場合、デザインモードが選択されている場合があるので開発タブのデザインモードの選択を解いてからコマンドボタンを押すようにしましょう。





2018/02/07

Excelで仮想通貨の資産管理3 -Excel VBA

前回は全銘柄を合計した円建ての資産総額を表示しました。

Excelで仮想通貨の資産管理2 -Excel VBA

今回は各銘柄の円建て資産額が全体の円建て資産額に占める割合(パーセンテージ)を表示したいと思います。F列の1番上のセルにpercentageを追加しました。
※D列に保有分の通貨数量を入力します。B列のシンボルも間違えないで正確に入力します。下記のように入力すればOKです。

・コード

Sub Crypto_JSON_In_Excel()
    Dim CryptoCurrencyJSON As Object, CryptoCurrencyNode
    Dim WinHttpReq As Object, TickerJSON As String
    Dim tickerSheet As Worksheet, arr(18) As Variant
    Dim val_jpy As Long
    Dim val_sum As Long
    Dim i As Integer
    Dim ii As Integer
 
       Set tickerSheet = ThisWorkbook.Sheets(1)

    arr(1) = "name"
    arr(2) = "symbol"
    arr(3) = "price_jpy"
    arr(4) = "holding"
    arr(5) = "value_jpy"
    arr(6) = "percentage"
    arr(7) = "percent_change_1h"
    arr(8) = "percent_change_24h"
    arr(9) = "percent_change_7d"


 
    Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
    WinHttpReq.Open "GET", "https://api.coinmarketcap.com/v1/ticker/?convert=JPY&limit=30", False
    WinHttpReq.send
    TickerJSON = WinHttpReq.responseText
    Set WinHttpReq = Nothing
 

    Set CryptoCurrencyJSON = ParseJson(TickerJSON)
 

    For i = 1 To 9
     
        tickerSheet.Cells(1, i) = arr(i)

    Next i
 
    trow = 2
    val_sum = 0
    For Each CryptoCurrencyNode In CryptoCurrencyJSON
    If UCase(Cells(trow, 2)) = CryptoCurrencyNode(arr(2)) Then
 
        For i = 1 To 9
     
            If i = 4 Then
                GoTo skip1
            Else: End If
     
            tickerSheet.Cells(trow, i) = CryptoCurrencyNode(arr(i))
skip1:
        Next
       val_jpy = Cells(trow, 3) * Cells(trow, 4)
       tickerSheet.Cells(trow, 5) = Application.WorksheetFunction.RoundDown(val_jpy, 0)
     
       val_sum = Cells(trow, 5) + val_sum
       trow = trow + 1

    Else: End If
     
    Next
    tickerSheet.Cells(trow, 5) = val_sum
 
    For ii = 2 To trow - 1
    tickerSheet.Cells(ii, 6) = Cells(ii, 5) / val_sum
    tickerSheet.Cells(ii, 6).NumberFormatLocal = "0.0%"
    Next
 
  With Range(Cells(2, i - 3), Cells(trow - 1, i - 1))

    .FormatConditions.AddColorScale ColorScaleType:=3
    .FormatConditions(Range(Cells(2, i - 3), Cells(trow - 1, i - 1)).FormatConditions.Count).SetFirstPriority
    .FormatConditions(1).ColorScaleCriteria(1).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(1).Value = -100
    .FormatConditions(1).ColorScaleCriteria(1).FormatColor.Color = 7039480

 
    .FormatConditions(1).ColorScaleCriteria(2).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(2).Value = 0
    .FormatConditions(1).ColorScaleCriteria(2).FormatColor.ThemeColor = xlThemeColorDark1


    .FormatConditions(1).ColorScaleCriteria(3).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(3).Value = 100
    .FormatConditions(1).ColorScaleCriteria(3).FormatColor.Color = 8109667
  End With

End Sub

●実行結果
F列にそれぞれの銘柄の保有割合が表示されました。


Excelで仮想通貨の資産管理4 -Excel VBA

無料・ダウンロード可) 仮想通貨エクセルツール2 各国法定通貨換算可能!仮想通貨価格・時価総額データ表示アプリケーション -Excel VBA

Excelで仮想通貨の資産管理2 -Excel VBA

前回はcoinmarketcap.comからAPIを利用して、任意の銘柄ごとに保有数量に応じて日本円換算した資産額を出しました。

Excelで仮想通貨の資産管理1 -Excel VBA

今回は全銘柄を合計した資産額を出したいと思います。
これが前回の実行結果です。

・コード
今回の変更は各銘柄の金額の足し算のみになりますのでプログラムの一部を変更するだけとなります。下記が変更した部分となります。

    trow = 2
    val_sum = 0
    For Each CryptoCurrencyNode In CryptoCurrencyJSON
    If UCase(Cells(trow, 2)) = CryptoCurrencyNode(arr(2)) Then
 
        For i = 1 To 8
     
            If i = 4 Then
                GoTo skip1
            Else: End If
     
            tickerSheet.Cells(trow, i) = CryptoCurrencyNode(arr(i))
skip1:
        Next
       val_jpy = Cells(trow, 3) * Cells(trow, 4)
       tickerSheet.Cells(trow, 5) = Application.WorksheetFunction.RoundDown(val_jpy, 0)
     
       val_sum = Cells(trow, 5) + val_sum   '資産総額
       trow = trow + 1

    Else: End If
     
    Next
    tickerSheet.Cells(trow, 5) = val_sum

●実行結果
E7のセルに資産総額が表示されました。


Excelで仮想通貨の資産管理3 -Excel VBA

無料・ダウンロード可) 仮想通貨エクセルツール2 各国法定通貨換算可能!仮想通貨価格・時価総額データ表示アプリケーション -Excel VBA

bitFlyer ビットコインを始めるなら安心・安全な取引所で

2018/02/06

Excelで仮想通貨の資産管理1 -Excel VBA

前回はcoinmarketcap.comからAPIを利用してデータを読み込み、任意の銘柄のみを表示するようにしました。
ExcelにCryptocurrency market capのデータを出力する5 -Excel VBA

今回は自分の保有通貨の数量を入力し、日本円換算の資産額を表示したいと思います。
D列に保有分の通貨数量を入力します。B列のシンボルも間違えないで正確に入力します。下記のように入力すればOKです。

コードは下記となります。

Sub Crypto_JSON_In_Excel()
    Dim CryptoCurrencyJSON As Object, CryptoCurrencyNode
    Dim WinHttpReq As Object, TickerJSON As String
    Dim tickerSheet As Worksheet, arr(8) As Variant
    Dim val_jpy As Long
 
    Set tickerSheet = ThisWorkbook.Sheets(1)

    arr(1) = "name"
    arr(2) = "symbol"
    arr(3) = "price_jpy"
    arr(4) = "holding"
    arr(5) = "value_jpy"
    arr(6) = "percent_change_1h"
    arr(7) = "percent_change_24h"
    arr(8) = "percent_change_7d"



 
    Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
    WinHttpReq.Open "GET", "https://api.coinmarketcap.com/v1/ticker/?convert=JPY&limit=30", False
    WinHttpReq.send
    TickerJSON = WinHttpReq.responseText
    Set WinHttpReq = Nothing
 

    Set CryptoCurrencyJSON = ParseJson(TickerJSON)
 

    For i = 1 To 8
     
        tickerSheet.Cells(1, i) = arr(i)

    Next i
 

    trow = 2
    For Each CryptoCurrencyNode In CryptoCurrencyJSON
    If UCase(Cells(trow, 2)) = CryptoCurrencyNode(arr(2)) Then
 
        For i = 1 To 8
     
            If i = 4 Then
                GoTo skip1
            Else: End If
     
            tickerSheet.Cells(trow, i) = CryptoCurrencyNode(arr(i))
skip1:
        Next
       val_jpy = Cells(trow, 3) * Cells(trow, 4)
       Cells(trow, 5) = Application.WorksheetFunction.RoundDown(val_jpy, 0)
       trow = trow + 1

    Else: End If
     
    Next
 
 
  With Range(Cells(2, i - 3), Cells(trow - 1, i - 1))

    .FormatConditions.AddColorScale ColorScaleType:=3
    .FormatConditions(Range(Cells(2, i - 3), Cells(trow - 1, i - 1)).FormatConditions.Count).SetFirstPriority
    .FormatConditions(1).ColorScaleCriteria(1).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(1).Value = -100
    .FormatConditions(1).ColorScaleCriteria(1).FormatColor.Color = 7039480

 
    .FormatConditions(1).ColorScaleCriteria(2).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(2).Value = 0
    .FormatConditions(1).ColorScaleCriteria(2).FormatColor.ThemeColor = xlThemeColorDark1


    .FormatConditions(1).ColorScaleCriteria(3).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(3).Value = 100
    .FormatConditions(1).ColorScaleCriteria(3).FormatColor.Color = 8109667
  End With

End Sub

●実行結果
実行するとcoinmarketcap.comのサイトからデータを読み込んで表示します。
E列には各通貨の日本円換算した資産額が表示されます。


Excelで仮想通貨の資産管理2 -Excel VBA

無料・ダウンロード可) 仮想通貨エクセルツール2 各国法定通貨換算可能!仮想通貨価格・時価総額データ表示アプリケーション -Excel VBA


bitFlyer ビットコインを始めるなら安心・安全な取引所で

ExcelにCryptocurrency market capのデータを出力する5 -Excel VBA

今回は任意の銘柄のデータを表示するようにしたいと思います。

表示する銘柄は適当にBit coin, Ethereum, Ripple, Lite coin, Liskとします。
他のADAとかEOSなどは表示しないようにします。

①まずは、下記の通りにExcelのシートのB列のsymbleのセルに銘柄のシンボル名を入力します。


②下記のコードを実行します。

Sub Crypto_JSON_In_Excel()
    Dim CryptoCurrencyJSON As Object, CryptoCurrencyNode
    Dim WinHttpReq As Object, TickerJSON As String
    Dim tickerSheet As Worksheet, arr(10) As Variant
 

    Set tickerSheet = ThisWorkbook.Sheets(1)


    arr(1) = "name"
    arr(2) = "symbol"
    arr(3) = "price_jpy"
    arr(4) = "price_btc"
    arr(5) = "24h_volume_jpy"
    arr(6) = "market_cap_jpy"
    arr(7) = "available_supply"
    arr(8) = "percent_change_1h"
    arr(9) = "percent_change_24h"
    arr(10) = "percent_change_7d"



 

    Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
    WinHttpReq.Open "GET", "https://api.coinmarketcap.com/v1/ticker/?convert=JPY&limit=30", False
    WinHttpReq.send
    TickerJSON = WinHttpReq.responseText
    Set WinHttpReq = Nothing
    'TickerJSON = DU("https://api.coinmarketcap.com/v1/ticker/")
 

    Set CryptoCurrencyJSON = ParseJson(TickerJSON)
 

    For i = 1 To 10
        tickerSheet.Cells(1, i) = arr(i)
    Next i
 

    trow = 2
    For Each CryptoCurrencyNode In CryptoCurrencyJSON
    If UCase(Cells(trow, 2)) = CryptoCurrencyNode(arr(2)) Then
 
        For i = 1 To 10
            tickerSheet.Cells(trow, i) = CryptoCurrencyNode(arr(i))
        Next
       trow = trow + 1

    Else: End If
     
    Next
 
 
  With Range(Cells(2, i - 3), Cells(trow - 1, i - 1))

    .FormatConditions.AddColorScale ColorScaleType:=3
    .FormatConditions(Range(Cells(2, i - 3), Cells(trow - 1, i - 1)).FormatConditions.Count).SetFirstPriority
    .FormatConditions(1).ColorScaleCriteria(1).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(1).Value = -100
    .FormatConditions(1).ColorScaleCriteria(1).FormatColor.Color = 7039480

 
    .FormatConditions(1).ColorScaleCriteria(2).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(2).Value = 0
    .FormatConditions(1).ColorScaleCriteria(2).FormatColor.ThemeColor = xlThemeColorDark1


    .FormatConditions(1).ColorScaleCriteria(3).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(3).Value = 100
    .FormatConditions(1).ColorScaleCriteria(3).FormatColor.Color = 8109667
  End With


End Sub

●実行結果
入力したシンボルに合わせてデータが表示されました。

2018/02/05

ExcelにCryptocurrency market capのデータを出力する4 -Excel VBA

今回は変動率に応じて色をつけたいと思います。
Excelでは条件次第でセルの色を変えることができます。条件付き書式から変えることができますが、VBAでも変えることができます。

変動率が0%より低いと赤色、0%を無色、0%より高いと緑色と設定します。
下限を-100%、上限を100%とします。
下限か上限に近づくにつれて色が段階的に濃くなるようグラデーションの設定にします。

Sub Crypto_JSON_In_Excel()
    Dim CryptoCurrencyJSON As Object, CryptoCurrencyNode
    Dim WinHttpReq As Object, TickerJSON As String
    Dim tickerSheet As Worksheet, arr(10) As Variant
 

    Set tickerSheet = ThisWorkbook.Sheets(1)

    arr(1) = "name"
    arr(2) = "symbol"
    arr(3) = "price_jpy"
    arr(4) = "price_btc"
    arr(5) = "24h_volume_jpy"
    arr(6) = "market_cap_jpy"
    arr(7) = "available_supply"
    arr(8) = "percent_change_1h"
    arr(9) = "percent_change_24h"
    arr(10) = "percent_change_7d"



 

    Set WinHttpReq = CreateObject("MSXML2.XMLHTTP")
    WinHttpReq.Open "GET", "https://api.coinmarketcap.com/v1/ticker/?convert=JPY&limit=50", False
    WinHttpReq.send
    TickerJSON = WinHttpReq.responseText
    Set WinHttpReq = Nothing

 

    Set CryptoCurrencyJSON = ParseJson(TickerJSON)
 

    For i = 1 To 10
        tickerSheet.Cells(1, i) = arr(i)
    Next i
 

    trow = 2
    For Each CryptoCurrencyNode In CryptoCurrencyJSON
        For i = 1 To 10
            tickerSheet.Cells(trow, i) = CryptoCurrencyNode(arr(i))
        Next
        trow = trow + 1
    Next
 
 
  With Range(Cells(2, i - 3), Cells(trow - 1, i - 1))

    .FormatConditions.AddColorScale ColorScaleType:=3
    .FormatConditions(Range(Cells(2, i - 3), Cells(trow - 1, i - 1)).FormatConditions.Count).SetFirstPriority
    .FormatConditions(1).ColorScaleCriteria(1).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(1).Value = -100
    .FormatConditions(1).ColorScaleCriteria(1).FormatColor.Color = 7039480

 
    .FormatConditions(1).ColorScaleCriteria(2).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(2).Value = 0
    .FormatConditions(1).ColorScaleCriteria(2).FormatColor.ThemeColor = xlThemeColorDark1


    .FormatConditions(1).ColorScaleCriteria(3).Type = xlConditionValueNumber
    .FormatConditions(1).ColorScaleCriteria(3).Value = 100
    .FormatConditions(1).ColorScaleCriteria(3).FormatColor.Color = 8109667
  End With


End Sub

●実行結果
変動率がプラスのものは緑、マイナスのものは赤となりました。