<?xml version="1.0" encoding="UTF-8"?><feed
	xmlns="http://www.w3.org/2005/Atom"
	xmlns:thr="http://purl.org/syndication/thread/1.0"
	xml:lang="ja"
	xml:base="https://postgresweb.com/wp-atom.php"
	>
	<title type="text">PostgresWeb &#8211; ポスグレウェブ</title>
	<subtitle type="text"></subtitle>

	<updated>2025-04-10T21:49:58Z</updated>

	<link rel="alternate" type="text/html" href="https://postgresweb.com" />
	<id>https://postgresweb.com/feed/atom</id>
	<link rel="self" type="application/atom+xml" href="https://postgresweb.com/feed/atom" />

	<generator uri="https://wordpress.org/" version="5.8.17">WordPress</generator>
<icon>https://postgresweb.com/wp-content/uploads/2021/07/cropped-postgresweb_siteicon2-32x32.jpg</icon>
	<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【VBA】配列の中身が空であるのを判定する]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/vba-determines-that-the-array-is-empty" />

		<id>https://postgresweb.com/?p=14921</id>
		<updated>2023-12-14T14:21:16Z</updated>
		<published>2023-12-14T14:20:29Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[配列に特定の要素が何番目に含まれるかをチェックする VBAで配列の中身が空であるのを判定する関数です。配列の中で１つでも値が入っていたら、「空でない」と判定します。文字、数値、日付などの配列にも対応。 &#160; '= [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/vba-determines-that-the-array-is-empty"><![CDATA[<h2>配列に特定の要素が何番目に含まれるかをチェックする</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">VBAで配列の中身が空であるのを判定する関数です。配列の中で１つでも値が入っていたら、「空でない」と判定します。文字、数値、日付などの配列にも対応。</span></p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-vbnet"><code>'=========================================================
'[概  要] 配列が空かどうかを判定する関数
'[引  数] arr ： チェック対象の配列
'[戻り値] True：空、False：空でない
'[備  考] 一つでも空でないものがある場合、「空でない」とみなす
'=========================================================
Function CheckArrayEmpty(arr As Variant) As Boolean
   
    If IsArray(arr) Then
        ' 配列が有効な場合
        Dim i As Long
        For i = LBound(arr) To UBound(arr)
            If (IsEmpty(arr(i)) Or IsNull(arr(i)) Or (VarType(arr(i)) = vbString And Len(arr(i)) = 0)) = False Then
                CheckArrayEmpty = False '空でない
                Exit Function
            End If
        Next i
        CheckArrayEmpty = True '空
    Else
        CheckArrayEmpty = True '空
    End If
   
End Function
</code></pre>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-vbnet"><code>'テスト実行
Dim testArr(2) As Variant

'値セットなし
Debug.Print CheckArrayEmpty(testArr) '結果：（True 空）

'すべてNull
testArr(0) = Null
testArr(1) = Null
testArr(2) = Null
Debug.Print CheckArrayEmpty(testArr) '結果：（True 空）

'文字列：一部に値をセット
testArr(0) = "a"
Debug.Print CheckArrayEmpty(testArr) '結果：（False 空でない）

'文字列：間に値をセット
testArr(0) = "a"
testArr(1) = ""
testArr(2) = "c"
Debug.Print CheckArrayEmpty(testArr) '結果：（False 空でない）

'数値：一部に値をセット
testArr(0) = 1
Debug.Print CheckArrayEmpty(testArr)  '結果：（False 空でない）

'数値：間に値をセット
testArr(0) = 1
testArr(1) = Null
testArr(2) = 3
Debug.Print CheckArrayEmpty(testArr)  '結果：（False 空でない）

'日付：一部に値をセット
testArr(0) = Now()
Debug.Print CheckArrayEmpty(testArr)  '結果：（False 空でない）

'日付：間に値をセット
testArr(0) = Now()
testArr(1) = Null
testArr(2) = DateAdd("d", 1, Now())
Debug.Print CheckArrayEmpty(testArr)  '結果：（False 空でない）
</code></pre>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[配列に特定の要素が何番目に含まれるかをチェックする]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/check-how-many-elements-are-included" />

		<id>https://postgresweb.com/?p=14910</id>
		<updated>2023-12-10T13:04:47Z</updated>
		<published>2023-12-10T12:52:17Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[配列に特定の要素が何番目に含まれるかをチェックする VBAで、配列に特定の要素が何番目に含まれるかをチェックするサンプルプログラムです。 &#160; '================================= [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/check-how-many-elements-are-included"><![CDATA[<h2>配列に特定の要素が何番目に含まれるかをチェックする</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">VBAで、配列に特定の要素が何番目に含まれるかをチェックするサンプルプログラムです。</span></p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-vbnet"><code>'=========================================================
'[概  要] 配列に特定の要素が何番目に含まれるかをチェックする
'[引数１] arr        : 探索対象の配列
'[引数２] SearchStr  : 探索する文字列
'[戻り値] 要素のある位置（配列の添え字）を返す（0～）
'[備考１] 取得した要素の番号は0始まり
'[備考２] ない場合、エラー時は-1で返す
'=========================================================
Public Function checkArrayContainElement(ByVal arr As Variant, ByVal SearchStr As String) As Integer

On Error GoTo ErrLabel
   
    For i = 0 To UBound(arr)
   
        '部分一致（検索文字を含んでいればOK）
        If InStr(arr(i), SearchStr) > 0 Then
            checkArrayContainElement = i
            Exit Function
        End If
       
        '完全一致ならこちらを使用する
        If arr(i) = SearchStr Then
            checkArrayContainElement = i
            Exit Function
        End If
   
    Next
   
    'ない場合は-1
    checkArrayContainElement = -1
   
ErrLabel:

    'エラー時も空とみなす
    checkArrayContainElement = -1
   
End Function
</code></pre>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-vbnet"><code>'上の関数のテスト実行
Dim testArr(2) As Variant

'すべてNull
testArr(0) = "あいう"
testArr(1) = "えお"
testArr(2) = "かきく"

MsgBox checkArrayContainElement(testArr, "う") '結果：0
MsgBox checkArrayContainElement(testArr, "お") '結果：1
MsgBox checkArrayContainElement(testArr, "さ") '結果：-1
</code></pre>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【VBA】イミディエイトウィンドウをクリアする]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/vba-clear-the-immediate-window" />

		<id>https://postgresweb.com/?p=14902</id>
		<updated>2023-12-10T13:07:25Z</updated>
		<published>2023-12-09T14:16:38Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[イミディエイトウィンドウをクリアする VBA実行時、イミディエイトウィンドウをきれいにしてから実行したいという人もいると思います。大きく①Debug.Printで改行を200回やる方法と、②SendKeyを使う方法とある [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/vba-clear-the-immediate-window"><![CDATA[<h2>イミディエイトウィンドウをクリアする</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">VBA実行時、イミディエイトウィンドウをきれいにしてから実行したいという人もいると思います。大きく①Debug.Printで改行を200回やる方法と、②SendKeyを使う方法とあるのですが、①Debug.Printだとうまく消えきらなかったため（前回のが残ってしまう）、SendKeyでやることにしました。SendKeyもどうかいう意見もあると思いますが、私の環境では問題なく使えているので是非使ってみてください。</span></p>
<p style="margin: 0px; line-height: 10px;"> </p>
<pre class="language-vbnet"><code>'=========================================================
'[概  要] イミディエイトウィンドウ内をクリアする
'[引　数] なし
'[戻り値] なし
'[備　考]
'=========================================================
Sub ClearImmediate()
   
    '誤動作防止：イミディエイトウィンドウが非表示だったら終了
    If Not Application.VBE.Windows("イミディエイト").Visible Then
        Exit Sub
    End If
   
    SendKeys "^g"          'イミディエイトウィンドウにフォーカス
    SendKeys "^a"          '全選択
    SendKeys "{Del}"       'Delete

End Sub</code></pre>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【VBA】VBComponentを使おうとしたときにエラーが発生]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/error-when-trying-to-use-vbcomponent" />

		<id>https://postgresweb.com/?p=14890</id>
		<updated>2023-12-08T13:26:46Z</updated>
		<published>2023-12-08T13:26:09Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[現象 VBAで「VBComponent」を使用しようとした際、「コンパイル エラー:ユーザ定義型は定義されていません。」と表示されたときの対処方法です。 &#160; &#160; 対処方法 次の２つの設定する必要があり [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/error-when-trying-to-use-vbcomponent"><![CDATA[<h2>現象</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">VBAで「VBComponent」を使用しようとした際、「コンパイル エラー:ユーザ定義型は定義されていません。」と表示されたときの対処方法です。</span></p>
<p><img loading="lazy" class="alignnone size-full wp-image-14894" src="https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent01.png" alt="" width="277" height="159" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>対処方法</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">次の２つの設定する必要があります。</span></p>
<p>&nbsp;</p>
<h3>①「Microsoft Visual Basic for Applications Extensibility x.x」を追加</h3>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">ツール＞参照設定＞「Microsoft Visual Basic for Applications Extensibility x.x」を追加</span></p>
<p style="margin: 0px; line-height: 34px;"><img loading="lazy" class="alignnone wp-image-14899 size-full" src="https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent03.png" alt="" width="455" height="317" srcset="https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent03.png 455w, https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent03-300x209.png 300w" sizes="(max-width: 455px) 100vw, 455px" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3>②VBAプロジェクトオブジェクトモデルへのアクセスを信頼するにチェックON</h3>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">EXCELのメニュー＞開発＞マクロの設定＞VBAプロジェクトオブジェクトモデルへのアクセスを信頼するにチェックON</span></p>
<p style="margin: 0px; line-height: 34px;"><img loading="lazy" class="alignnone wp-image-14896" src="https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02.png" alt="" width="600" height="433" srcset="https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02.png 950w, https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02-300x216.png 300w, https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02-768x554.png 768w, https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02-530x382.png 530w, https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02-565x407.png 565w, https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02-710x512.png 710w, https://postgresweb.com/wp-content/uploads/2023/12/Error-when-trying-to-use-VBComponent02-725x523.png 725w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"> </p>
<p>&nbsp;</p>
<p style="margin: 0px; line-height: 34px;"><span style="font-size: 15px;">これでできると思いますので、試してみて下さい。</span></p>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【VBA】Variant型のデメリット]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/disadvantages-of-variant-type" />

		<id>https://postgresweb.com/?p=14883</id>
		<updated>2023-12-07T13:16:31Z</updated>
		<published>2023-12-07T13:15:58Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[行間調整 Variantは非常に柔軟な型で、どんな種類のデータも格納できるため変数を宣言するのにとても便利です。「なんでもかんでもVariantを使えばいいじゃん！」と思いますが、Variantにもいくつかデメリットがあ [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/disadvantages-of-variant-type"><![CDATA[<h2>行間調整</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">Variantは非常に柔軟な型で、どんな種類のデータも格納できるため変数を宣言するのにとても便利です。「なんでもかんでもVariantを使えばいいじゃん！」と思いますが、Variantにもいくつかデメリットがあります。</span></p>
<p>&nbsp;</p>
<h3>①コードの可読性の低下</h3>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">変数は、他の開発者や自分自身にとって理解しやすい形であることが重要ですが、型を指定しないとその変数がどのようなデータを期待しているのかが不明確になり、可読性が低下する可能性があります。</span></p>
<p style="margin: 0px; line-height: 34px;">&nbsp;</p>
<h3>②メモリ使用量の増加</h3>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">Variantはオーバーヘッドがあるため、他の特定のデータ型よりもメモリ使用量が多くなり、実行速度が低下する可能性があります。</span></p>
<p style="margin: 0px; line-height: 34px;">&nbsp;</p>
<h3>③実行時エラーのリスク</h3>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">Variantは実行時に型変換が行われるため、型が一致しない場合に実行時エラーが発生する可能性があります。型を厳密に指定することで、コンパイル時にエラーを検出することができ、安全性が向上します。</span></p>
<p style="margin: 0px; line-height: 34px;"><span style="font-size: 15px;">デメリットを踏まえて、できるだけ具体的なデータ型を選択して変数を宣言することが、コードの安全性、可読性、およびパフォーマンス向上につながると思います。</span></p>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【VBA】２次元配列の指定した行に1次元配列を挿入する]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/vba-inserts-a-1d-array-into-the-specified-row-of-a-2d-array" />

		<id>https://postgresweb.com/?p=14876</id>
		<updated>2023-12-06T13:20:19Z</updated>
		<published>2023-12-06T13:17:21Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[２次元配列の指定した行に1次元配列を挿入する VBAで、2次元配列の指定した行に1次元配列を入れるサンプルプログラムです。 &#160; '======================================== [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/vba-inserts-a-1d-array-into-the-specified-row-of-a-2d-array"><![CDATA[<h2>２次元配列の指定した行に1次元配列を挿入する</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">VBAで、2次元配列の指定した行に1次元配列を入れるサンプルプログラムです。</span></p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-vbnet"><code>'=========================================================
'[概  要] ２次元配列の指定した行に1次元配列を挿入する
'[引数１] arr        : 2次元配列（この配列に挿入する）
'[引数２] rowIndex   : 挿入する行（0から始まるため注意）
'[引数３] newData    : 1次元配列（この配列を挿入する）
'[戻り値] 挿入後の配列
'[備　考]
'=========================================================
Function InsertAndShift(arr() As String, rowIndex As Integer, newData() As String) As String()

    Dim numRows As Integer
    Dim numCols As Integer
    numRows = UBound(arr, 1) + 1
    numCols = UBound(arr, 2) + 1

    ' 新しい行の追加
    Dim newArr() As String
    ReDim newArr(0 To numRows, 0 To numCols - 1)
    For i = 0 To numRows - 1
        For j = 0 To numCols - 1
            newArr(i, j) = arr(i, j)
        Next j
    Next i

    ' 指定位置以降のデータを後ろにシフト
    For i = numRows To rowIndex + 1 Step -1
        For j = 0 To numCols - 1
            newArr(i, j) = arr(i - 1, j)
        Next j
    Next i

    ' 新しいデータを挿入
    For j = 0 To numCols - 1
        newArr(rowIndex, j) = newData(j)
    Next j

    ' 結果の配列を返す
    InsertAndShift = newArr
   
End Function</code></pre>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-vbnet"><code>'上の関数のテスト実行
Sub TestInsertData()

    Dim arr() As String
    ReDim arr(0 To 1, 0 To 3)

    '2次元配列の初期値を設定
    arr(0, 0) = "a0"
    arr(0, 1) = "a1"
    arr(0, 2) = "a2"
    arr(0, 3) = "a3"
    arr(1, 0) = "b0"
    arr(1, 1) = "b1"
    arr(1, 2) = "b2"
    arr(1, 3) = "b3"
  
    '挿入するデータを定義
    Dim newData() As String
    ReDim newData(0 To 3)
    newData(0) = "c0"
    newData(1) = "c1"
    newData(2) = "c2"
    newData(3) = "c3"

    '★ここで実行
    'データを挿入してシフト
    arr = InsertAndShift(arr, 1, newData)

    'データの中身を表示する
    Dim i As Integer
    Dim j As Integer
    For i = LBound(arr, 1) To UBound(arr, 1)
        For j = LBound(arr, 2) To UBound(arr, 2)
            Debug.Print "arr(" & i & "," & j & ") = " & arr(i, j)
        Next j
    Next i
   
End Sub</code></pre>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【VBA】Debug.printで改行させない方法]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/vba-how-to-prevent-line-breaks-debug-print" />

		<id>https://postgresweb.com/?p=14865</id>
		<updated>2025-04-10T21:49:58Z</updated>
		<published>2023-12-05T12:43:48Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[行間調整 Debug.printではデフォルトで改行してしまいますが、これを防ぐにはprint文の最後に「;」をつけることで改行されなくすることが可能です。";"には"で囲む必要はないことに注意して下さい。 '改行して表 [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/vba-how-to-prevent-line-breaks-debug-print"><![CDATA[<h2>行間調整</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">Debug.printではデフォルトで改行してしまいますが、これを防ぐには<span style="background: linear-gradient(transparent 60%, yellow 0%);">print文の最後に「;」をつける</span>ことで改行されなくすることが可能です。";"には"で囲む必要はないことに注意して下さい。</span></p>
<pre class="language-vbnet"><code>'改行して表示する　最後に「;」をつけない
Debug.Print "a"

'改行なし
Debug.Print "a";
</code></pre>
<p style="margin: 0px; line-height: 10px;"> </p>
<p style="margin: 0px; line-height: 10px;"> </p>
<pre class="language-vbnet"><code>'実行テスト用
Sub ClearImmediateWindow()
    Dim i As Integer
   
    For i = 1 To 200
        '改行あり
        Debug.Print i
    Next i
   
    '改行せず表示するパターン　最後に「;」をつける
    For i = 1 To 200
        '改行なし
        Debug.Print i;
    Next i
   
End Sub


</code></pre>
<p><a href="https://px.a8.net/svt/ejp?a8mat=3TAU5D+FJNHF6+407E+5YRHE" rel="nofollow">全国送料無料！IT書、ビジネス書、資格書が豊富な『SEshop』</a><br />
<img loading="lazy" border="0" width="1" height="1" src="https://www14.a8.net/0.gif?a8mat=3TAU5D+FJNHF6+407E+5YRHE" alt=""></p>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【PowerShell】指定の文字列が先頭、または後方にあるかを調べる（前方一致、後方一致）]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/powershell-front-match-back-match" />

		<id>https://postgresweb.com/?p=14843</id>
		<updated>2023-12-04T13:24:49Z</updated>
		<published>2023-11-30T14:45:14Z</published>
		<category scheme="https://postgresweb.com" term="PowerShell" />
		<summary type="html"><![CDATA[指定の文字列が先頭にあるかを調べる（IndexOf） とある文字列に対し、指定した先頭にあるか（前方一致）を調べるには「StartsWith」または「like」を使用します。 $targetString = "testh [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/powershell-front-match-back-match"><![CDATA[<h2>指定の文字列が先頭にあるかを調べる（IndexOf）</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">とある文字列に対し、<span class="marker"><strong>指定した先頭にあるか（前方一致）</strong>を調べるには<strong>「StartsWith」または「like」</strong>を使用</span>します。</p>
<pre class="language-powershell"><code>$targetString = "testhogehoge"

# 文字列が「test」で始まるかどうかの判定（StartsWithを使う）
if ($targetString.StartsWith("test")) {
    Write-Host "文字列は「test」で始まっています。"
} else {
    Write-Host "文字列は「test」で始まっていません。"
}

# 文字列が「test」で始まるかどうかの判定（likeを使う）
if ($targetString -like "test*") {
    Write-Host "文字列は「test」で始まっています。"
} else {
    Write-Host "文字列は「test」で始まっていません。"
}
</code></pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>指定の文字列が後方にあるかを調べる（IndexOf）</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">とある文字列に対し、<span class="marker"><strong>指定した後方にあるか（後方一致）</strong>を調べるには<strong>「EndsWith」または「like」</strong>を使用</span>します。</p>
<pre class="language-powershell"><code>$targetString = "hogehogetest"

# 文字列が「test」で終わるかどうかの判定（EndsWithを使う）
if ($targetString.EndsWith("test")) {
    Write-Host "文字列は「test」で終わっています。"
} else {
    Write-Host "文字列は「test」で終わっていません。"
}

# 文字列が「test」で終わるかどうかの判定（likeを使う）
if ($targetString -like "*test") {
    Write-Host "文字列は「test」で終わっています。"
} else {
    Write-Host "文字列は「test」で終わっていません。"
}
</code></pre>
<p>&nbsp;</p>
<div class="box104"><span class="box-title">あわせて読みたい</span></p>
<p>特定の文字が含まれるかを調べる方法はこちらです。</p>
<p><a href="https://postgresweb.com/powershell-check-if-the-character-contains" target="_blank" rel="noopener noreferrer" data-blogcard="1">前方一致、後方一致の方法はこちら</a></p>
</div>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【PowerShell】このシステムではスクリプトの実行が無効になっているため…の対処方法]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/because-script-execution-is-disabled-on-this-system" />

		<id>https://postgresweb.com/?p=14823</id>
		<updated>2023-11-29T13:14:30Z</updated>
		<published>2023-11-29T13:12:18Z</published>
		<category scheme="https://postgresweb.com" term="PowerShell" />
		<summary type="html"><![CDATA[エラーメッセージの対応方法 PowerShellで.psファイルを実行しようとした時、「このシステムではスクリプトの実行が無効になっているため、ファイル・・・を読み込むことができません。詳細については、・・・」と表示され [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/because-script-execution-is-disabled-on-this-system"><![CDATA[<h2>エラーメッセージの対応方法</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">PowerShellで.psファイルを実行しようとした時、「このシステムではスクリプトの実行が無効になっているため、ファイル・・・を読み込むことができません。詳細については、・・・」と表示された時の対応方法です。対応方法は３ステップでOK。</span></p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-powershell"><code># １．powershellを管理者権限で実行

# ２．このコマンドを実行する
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

# ３．「Y」を入力し、ENTER（小文字のｙでもOK）

# ※ PowerShell ISEを起動していたら再起動し、再度実行して下さい
</code></pre>
]]></content>
		
			</entry>
		<entry>
		<author>
			<name>tatsuki</name>
					</author>

		<title type="html"><![CDATA[【VBA】最終行を取得する、最終列を取得する]]></title>
		<link rel="alternate" type="text/html" href="https://postgresweb.com/vba-get-the-last-row" />

		<id>https://postgresweb.com/?p=14819</id>
		<updated>2023-11-27T14:28:46Z</updated>
		<published>2023-11-27T14:27:12Z</published>
		<category scheme="https://postgresweb.com" term="VBA" />
		<summary type="html"><![CDATA[最終行を取得する、最終列を取得する エクセルでデータのある最終行を取得する方法と、データのある最終列を取得する方法を紹介します。 &#160; '最終行を取得する Worksheets(シート名).Cells(Rows. [&#8230;]]]></summary>

					<content type="html" xml:base="https://postgresweb.com/vba-get-the-last-row"><![CDATA[<h2>最終行を取得する、最終列を取得する</h2>
<p style="margin: -15px 0px 0px 0px; line-height: 34px;"><span style="font-size: 15px;">エクセルでデータのある最終行を取得する方法と、データのある最終列を取得する方法を紹介します。</span></p>
<p style="margin: 0px; line-height: 10px;">&nbsp;</p>
<pre class="language-vbnet"><code>'最終行を取得する
Worksheets(シート名).Cells(Rows.Count, 最終行をチェックする列番号).End(xlUp).Row

'実行例
Worksheets(シート名).Cells(Rows.Count, 1).End(xlUp).Row


'最終列を取得する
Worksheets(シート名).Cells(最終行をチェックする行番号, Columns.Count).End(xlToLeft).Column

'実行例
Worksheets(シート名).Cells(1, Columns.Count).End(xlToLeft).Column
</code></pre>
]]></content>
		
			</entry>
	</feed>
