fix: 選択営業所/物件状況チェックの型不一致エラー(実行時エラー13)を解消

Range(...).Valueが配列やエラー値を返すケースでTrimが型不一致エラーになっていた。
Cells(1,1)で単一セル値を取得し、IsErrorチェック+CStrで文字列化してから判定するよう修正。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Kenichiro NOGI 2026-09-18 18:29:48 +09:00
parent bc03b2d47b
commit b9150c0461

View File

@ -22,7 +22,13 @@ Sub run()
Call init Call init
'入力チェック(営業所・物件状況が未選択なら処理中断) '入力チェック(営業所・物件状況が未選択なら処理中断)
If Trim(Range("Ið‰cÆ<E280B9>Š").Value) = "" Or Trim(Range("•¨Œ<C2A8><C592>óµ").Value) = "" Then Dim selSalesOffice As Variant, selPropertyStatus As Variant
selSalesOffice = Range("Ið‰cÆ<E280B9>Š").Cells(1, 1).Value
selPropertyStatus = Range("•¨Œ<C2A8><C592>óµ").Cells(1, 1).Value
If IsError(selSalesOffice) Then selSalesOffice = ""
If IsError(selPropertyStatus) Then selPropertyStatus = ""
If Trim(CStr(selSalesOffice)) = "" Or Trim(CStr(selPropertyStatus)) = "" Then
MsgBox "営業所と物件状況は必ず選択してください", vbExclamation MsgBox "営業所と物件状況は必ず選択してください", vbExclamation
Exit Sub Exit Sub
End If End If