G
Guest
What I'm trying to do for each in the range a2:a6 in a spreadsheet is to
store the date in it, then to search row 1 for the same date, and to put the
number 1 and colour sky blue into the cell which is in the same row as the
first instance of the date and the same column as the second instance of the
date, i.e. the intersection of first instance's row and the second instance's
column. Don't ask! Thanks for any help figuring how to fix run time error
91!
Option Explicit
Sub macro1()
Dim r As Integer
Dim c As Integer
Dim d As Date
For r = 2 To 6
d = Cells(r, 1).Value
Cells(1, 1).Select
Cells.Find(What:=d, After:=ActiveCell, LookIn:=xlValues,
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate
c = ActiveCell.Column
Cells(r, c).Select
ActiveCell.Value = 1
ActiveCell.Interior.ColorIndex = 33
Next r
End Sub
store the date in it, then to search row 1 for the same date, and to put the
number 1 and colour sky blue into the cell which is in the same row as the
first instance of the date and the same column as the second instance of the
date, i.e. the intersection of first instance's row and the second instance's
column. Don't ask! Thanks for any help figuring how to fix run time error
91!
Option Explicit
Sub macro1()
Dim r As Integer
Dim c As Integer
Dim d As Date
For r = 2 To 6
d = Cells(r, 1).Value
Cells(1, 1).Select
Cells.Find(What:=d, After:=ActiveCell, LookIn:=xlValues,
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate
c = ActiveCell.Column
Cells(r, c).Select
ActiveCell.Value = 1
ActiveCell.Interior.ColorIndex = 33
Next r
End Sub