1
2

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.

Excel VBA 小技

Last updated at Posted at 2020-10-14

Excel VBAの覚書的小技集

VBAで絵文字

UNICODEを直接埋め込む方法。
ワークシート関数のUnicha関数を使う。

Call r.Replace("A", Application.WorksheetFunction.Unichar(&H1F60D)) '範囲にあるAを😍に置換

ワークシートの有無

ループしないでワークシートの有無を調べる方法。
どのブックから探すのかを指定する方法と、戻り値を設定する方法が素敵。
以下からの引用
https://stackoverflow.com/questions/6040164/if-worksheetwsname-exists/6040390#6040390
日本語の解説はこちら
https://mk-55.hatenablog.com/entry/2017/05/24/003159

Public Function SheetExists(byval SheetName As String, Optional wb As Excel.Workbook) as Boolean
    Dim s As Excel.Worksheet
    If wb Is Nothing Then Set wb = ThisWorkbook
    On Error Resume Next
    Set s = wb.Sheets(SheetName)
    On Error GoTo 0
    SheetExists = Not s Is Nothing
End Function
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?