| 
    
     |  | A〜G列(常に固定)に、名前、社員番号、連絡先、出勤時間、退社時間などの情報があり、G列に出勤・退社時間を計算した「勤務時間」があります。 そこで、作成したマクロは;
 
 1.G列が空欄なら、その行(A〜G列まで)すべての背景を薄いグレー、文字を濃いグレーに、条件付き書式で変更。
 
 2.新しいシートへ書き出し
 
 というものです。
 しかし、行は常に変動するため、問題が起きています。
 設定をしたときは、行が37までしかなかったので、その後、行を追加しても、37行目以降のものはすべて削除されて抽出されてしまいます。
 
 長いですが、以下を見ていただけると助かります。
 
 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
 Sub Macro6()
 
 Sheets("Conference Report").Select
 Sheets("Conference Report").Copy
 ActiveSheet.Shapes("Rectangle 1").Select
 Selection.Cut
 ActiveSheet.Shapes("Rectangle 4").Select
 Selection.Cut
 Range("B8").Select
 Selection.ClearContents
 Rows("7:9").Select
 Selection.Delete Shift:=xlUp
 Rows("7:7").Select
 Selection.Delete Shift:=xlUp
 Range("B9").Select
 ActiveWindow.SmallScroll Down:=15
 Range("G19:G200").Select
 Selection.FormatConditions.Delete
 Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
 Formula1:="="""""
 Selection.FormatConditions(1).Font.ColorIndex = 16
 Selection.FormatConditions(1).Interior.ColorIndex = 15
 ActiveWindow.SmallScroll Down:=9
 Range("A19:F37").Select
 Selection.FormatConditions.Delete
 Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$G19="""""
 Selection.FormatConditions(1).Font.ColorIndex = 16
 Selection.FormatConditions(1).Interior.ColorIndex = 15
 Range("A18").Select
 Selection.End(xlDown).Select
 Selection.End(xlToRight).Select
 ActiveWindow.SmallScroll Down:=0
 Range("A19:F200").Select
 ActiveWindow.SmallScroll Down:=-66
 Selection.FormatConditions.Delete
 Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$G19="""""
 Selection.FormatConditions(1).Font.ColorIndex = 16
 Selection.FormatConditions(1).Interior.ColorIndex = 15
 ActiveWindow.SmallScroll Down:=3
 Range("A19").Select
 Selection.End(xlDown).Select
 Selection.End(xlToRight).Select
 ActiveWindow.SmallScroll Down:=9
 Rows("38:221").Select
 Selection.Delete Shift:=xlUp
 Range("A37").Select
 Selection.End(xlUp).Select
 ActiveWindow.SmallScroll Down:=-27
 Range("A10").Select
 End Sub
 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
 
 本当に初心者で、こんなことをすることじたいが正しいのかも分かりません。
 どなたか、ご教授いただけますでしょうか。
 よろしくお願いします。
 
 |  |