
対象となる文字列の中に、指定した文字列が
・先頭にあるか
・末尾にあるか
を確認する方法を記載します!

「Like演算子」によって実現します!
指定した文字列が先頭にあるかを確認する
ここでは例として、
・対象となる文字列「20201221」を変数「targetStr」に設定し、
・先頭に「2020」があるかを確認する
VBAコードを記載します。
Option Explicit
Sub sample()
Dim targetStr As String
'対象となる文字列
targetStr = "20201221"
'先頭に「2020」があるかを確認する
If (targetStr Like "2020*") Then
MsgBox ("2020年です。")
Else
MsgBox ("2020年ではないです。")
End If
End Sub
上記を実行すると、メッセージ「2020年です。」が表示されます。

「対象となる文字列」を以下に変更して実行すると、メッセージ「2020年ではないです。」が表示されます。
・20211221 ←「2020」が無い
・20220201 ←真ん中に「2020」がある
・20212020 ←末尾に「2020」がある

指定した文字列が末尾にあるかを確認する
ここでは例として、
・対象となる文字列「20201221」を変数「targetStr」に設定し、
・末尾に「1221」があるかを確認する
VBAコードを記載します。
Option Explicit
Sub sample()
Dim targetStr As String
'対象となる文字列
targetStr = "20201221"
'末尾に「1221」があるかを確認する
If (targetStr Like "*1221") Then
MsgBox ("12月21日です。")
Else
MsgBox ("12月21日ではないです。")
End If
End Sub
上記を実行すると、メッセージ「12月21日です。」が表示されます。

「対象となる文字列」を以下に変更して実行すると、メッセージ「12月21日ではないです。」が表示されます。
・20201220 ←「1221」が無い
・20212211 ←真ん中に「1221」がある
・12219999 ←先頭に「1221」がある
