下記の処理を停止することで負荷を軽減できます。
なお、処理後は元に戻す処理を入れましょう。
' 画面の更新を無効 Application.ScreenUpdating = False
' マクロのイベントを無効 Application.EnableEvents = False
' シートの再計算を無効 ActiveSheet.EnableCalculation = False
' 条件付き書式の再計算を無効 ActiveSheet.EnableFormatConditionsCalculation = False
Function 文字列の検索(対象列 As Range, 検索文字 As String) As Long Dim 一致セル As Range: Set 一致セル = 対象列.Find(What:=検索文字, LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False) If Not 一致セル Is Nothing Then 文字列の検索 = 一致セル.Row() Else 文字列の検索 = 0 End If End Function
Dim 行数 As String: 行数 = 文字列の検索(シート.Columns("A:A"), 更新ID)
Dim ID As String: ID = Application.InputBox(Prompt:="表示するIDを入力してください", Title:="データ表示") If hoge = "False" Then MsgBox "キャンセルされました" Exit Sub End If Debug.Print ID
Sub アクティブセルが指定セル範囲内にあるかを調べる() Set 指定セル範囲 = Range("A1:C5") Set 共有セル範囲 = Intersect(ActiveCell, 指定セル範囲) If Not 共有セル範囲 Is Nothing Then MsgBox "アクティブセルは指定セル範囲内にあります。" End If End Sub