0
0

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 3 years have passed since last update.

【ExcelVBA】Long(数値)型を文字列型に置き換えるメモ

Last updated at Posted at 2021-02-04

トピックについて

  • 数値型を文字列型にする関数のメモ
  • 単純な話Trim(str(val))で済む話だけど、個人的に見栄えを良くしたくて、いつもFunctionを作成している。

◎2021/02/06追記---->
@radames1000様よりご指摘いただきました。
わざわざ関数作る必要なかった!!!
CStr(num)
以下の関数じゃなくて↑を使います!!
-------------------<

ソースコード・・・

'-------------------------------------
'引数に指定されたlong型の数値を文字列に置き換える
'[引数]
'num : 文字列に変換したいlong型の数字
'[戻り値]
'string : 引数を文字列に変換した値(スペースも取り除く)
'-------------------------------------
Function cnvStr( _
  ByVal num As Long _
) As String
'-------------------------------------
  cnvStr = Trim(Str(num))
End Function

メモ

● 単純にTrim(str(val))ではなくcnvStr(val)が好きなだけです。関数名は短ければなんでもOKです。
● を出来るだけ少なくしたい。
● A1C1形式でRangeでアクセスするときに良く使っています。

0
0
3

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?