top of page

SEARCH BY TAGS: 

RECENT POSTS: 

EXCEL VBAのさまざまな処理例

  • 執筆者の写真: takedacozy
    takedacozy
  • 2019年6月1日
  • 読了時間: 1分

以下は、自分がVBAを使う上でのサンプル。

最初の定義部分

Dim ws    As Worksheet

Set   ws =   Sheets("Sheet1")

Dim 行最上行 Sub データ関連性のチェックMacro()

'初期処理 行最上行 = 8 行最下行 = 50 '**s を探して、なかったらエラー For i = 1 To 500 If Cells(i, 列定義表示) = "*start" Then 行最上行 = i Exit For End If If i = 500 Then MsgBox  "*start がありません。終了します。"

end End If Next i

'**e を探して、なかったらエラー For i = 1 To 500 If Cells(i, 列定義表示) = "*end" Then 行最下行 = i Exit For End If If i = 500 Then MsgBox "*end がありません。終了します。" End End If Next i 'チェック範囲の値をクリアする Range(Cells(行最上行, 10), Cells(行最下行, 10)).ClearContents For x =  1 To 100 '全部項目が空欄のときは、処理を飛ばそう If Cells(x, 列日付) = ""  And  Cells(x, 列開始時刻) = ""  Then GoTo nextforへ End If w_差分 = Format(Cells(x, 列終了時刻) - Cells(x, 列開始時刻), "hh:mm") If w_差分 < Format(Cells(x, 列実働時間), "hh:mm") Then   Cells(x, 列自動チェック表示) = "実働時間が過大。" & w_差分 End If nextforへ: Next x Cotinueは無いので、ラベルにジャンプすること End Sub

 
 
 

Commentaires


bottom of page