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?

【Excel VBA】LCase関数とUCase関数|大文字⇔小文字の変換方法と注意点

Last updated at Posted at 2025-07-07

LCase関数とUCase関数の使い方と注意点

LCase関数UCase関数は、文字列の中のアルファベットの大文字と小文字を置き換える関数です。

  • LCase関数 : 文字列中の大文字を小文字に置き換えます。
  • UCase関数 : 文字列中の小文字を大文字に置き換えます。

構文

LCase(文字列)
UCase(文字列)
  • 文字列 : 大文字⇔小文字の置換する文字列
  • 戻り値 : 置換後の文字列

使用例

こちらの例ではExcelという文字列に対し、LCase関数とUCase関数を実行しています。

Sub Sample()
    Dim mystring As String
    
    mystring = "Excel"
    
    Debug.Print "LCase : " & LCase(mystring)
    Debug.Print "UCase : " & UCase(mystring)
End Sub

▶ 出力結果

LCase : excel
UCase : EXCEL

LCase関数では全てが小文字に、
UCase関数では全てが大文字に変換されています。

⚠️注意

変換はアルファベットのみ

変換が行われるのは全角/半角の英字のみです。

Sub Sample()
    Dim mystring As String
    
    mystring = "Abc Abc あいう アイウ 亜伊宇 012 012 !?# !?#"
    '半角英字、全角英字、ひらがな、カタカナ、漢字、半角数字、全角数字、半角記号、全角記号

    Debug.Print "LCase : " & LCase(mystring)
    Debug.Print "UCase : " & UCase(mystring)
End Sub

▶ 出力結果

LCase : abc abc あいう アイウ 亜伊宇 012 012 !?# !?#
UCase : ABC ABC あいう アイウ 亜伊宇 012 012 !?# !?#

その他のVBA関数

【Excel VBA】VBAでよく使う関数一覧&基本の使い方

参考リンク

0
0
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
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?