C
Carolyn
Hi - Thanks Tom Ogilvy for the code! And the link to the tutorial.
It's making more sense now.
Now I'd like to loop through the code so that it will run for each
cell in a column that has data. I'd also like it to check row 2 in
several worksheets.
Sub MarkDate()
Dim dt As Long
Dim desc As String
Dim rng As Range, rng1 As Range, res As Variant
Dim cell As Range
Dim cl As Integer
'I need the following to execute for every cell
'in column B with a value and not just for cell B1
Set rng = Worksheets("WorksheetA").Range("B1")
dt = rng.Value
desc = rng.Offset(0, -1).Value
cl = rng.Offset(0, 1).Value
'Is it possible to have the code search Row 2 in several sheets
'all in one bit of code? Or would it be better to write this
'for each worksheet I want checked (WorksheetB, WorksheetC, ...)
Set rng1 = Worksheets("WorksheetB").Rows(2).Cells
res = Application.Match(dt, rng1, 0)
If Not IsError(res) Then
Set cell = rng1(1, res)
cell.EntireColumn.Interior.ColorIndex = cl
cell.Offset(3, 0).Value = desc
End If
End Sub
It's making more sense now.
Now I'd like to loop through the code so that it will run for each
cell in a column that has data. I'd also like it to check row 2 in
several worksheets.
Sub MarkDate()
Dim dt As Long
Dim desc As String
Dim rng As Range, rng1 As Range, res As Variant
Dim cell As Range
Dim cl As Integer
'I need the following to execute for every cell
'in column B with a value and not just for cell B1
Set rng = Worksheets("WorksheetA").Range("B1")
dt = rng.Value
desc = rng.Offset(0, -1).Value
cl = rng.Offset(0, 1).Value
'Is it possible to have the code search Row 2 in several sheets
'all in one bit of code? Or would it be better to write this
'for each worksheet I want checked (WorksheetB, WorksheetC, ...)
Set rng1 = Worksheets("WorksheetB").Rows(2).Cells
res = Application.Match(dt, rng1, 0)
If Not IsError(res) Then
Set cell = rng1(1, res)
cell.EntireColumn.Interior.ColorIndex = cl
cell.Offset(3, 0).Value = desc
End If
End Sub