0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

初心者VBAを使いExcelでShift JISへの変換関数調査ノート

Posted at

ExcelでShift JISへの文字コード変換をしたかったのですが、標準でExcelに搭載されている関数になかったので、情報を集めながら作成したときのノートを書きたいと思います。

・環境
Windows :11
Excel :バージョン 2023

参考サイト

-「ExcelマクロVBA入門編」
https://excel-ubara.com/excel_vba1.html
-「VBAでの文字コードの取得」
https://office-fun.com/dev-vba-character-encoding/
-「Office VBA リファレンス」
https://learn.microsoft.com/ja-jp/office/vba/api/overview/

目次

 作業準備
 用語整理
 実行
 まとめ

作業準備

用語としては聞いたことがあったのですが、そもそもVBAとは何か、マクロを使うため準備は何をしたらよいかがわからなかったので、以下のサイトを参考にExcelを触りながら理解をしていきました。
ClosedXMLを触っていたので、セル範囲の指定などは、比較的簡単に理解することができました。

-「ExcelマクロVBA入門編」
https://excel-ubara.com/excel_vba1.html

用語整理

参考サイトのわからなかった部分をまとめます。
-「VBAでの文字コードの取得」
https://office-fun.com/dev-vba-character-encoding/

使っているデータの型

データ型 概要 用途
Long 長整数型 -2,147,483,648 ~ 2,147,483,647の範囲の整数
String 文字列型 最大約20億文字までの文字列を表現
Variant バリアント型 すべてのデータを表現

関数

関数名 引数 返り値のデータ型 用途
CLng 任意のString型または数式 Long型 引数を評価し整数型を返す/16進数→10進数に変換
Mid String型, Long型 [,Variant型(Long型)] String型 第一引数のString型をLong型指定の位置から切り抜く。開始位置の添え字は1

実行

開発のマクロから参考サイトの関数を登録することでShift JISへ変換関数を実行することができました。

image.png

まとめ

マクロを初めて使ってみてExcelにこんな使い方があるとは知らなかったです!
VBAの知識を広げて定型的に行っているOfficeアプリ系の事務処理を楽にできたらいいなと思いました!

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?