|
ループをA列〜D列までにしたいのですが
どうしたらよいでしょうか?現在はLoop Until ""で何もなかったら
抜けるにしてあります。範囲を設定したいのですが初心者なのでわかりません
どなたか教えてください。
Sub 後シート色づけ()
Dim Ans1 As Variant
Dim Ans2 As Variant
Dim NewXcel As Long
Dim NewYcel As Long
Dim OldXcel As Long
Dim OldYcel As Long
Dim ites As Variant
Dim Obj1 As Variant
NewYcel = 2
Do
Ans1 = Sheets("後").Cells(NewYcel, 1)
Set Obj1 = Worksheets("前").Cells.Find(Ans1)
If Obj1 Is Nothing Then
Sheets("後").Cells.Find(Ans1).Interior.ColorIndex = 27
Else
NewXcel = 2
OldXcel = 2
OldYcel = Worksheets("前").Cells.Find(Ans1).Row
Do
If Worksheets("前").Cells(OldYcel, OldXcel) = Worksheets("後").Cells(NewYcel, NewXcel) Then
Else
Worksheets("後").Cells(NewYcel, NewXcel).Interior.ColorIndex = 27
End If
NewXcel = NewXcel + 1
OldXcel = OldXcel + 1
Ans2 = Sheets("後").Cells(NewYcel, NewXcel)
Loop Until Ans2 = ""
End If
NewYcel = NewYcel + 1
ites = Sheets("後").Cells(NewYcel, 1)
Loop Until ites = ""
End Sub
|
|