View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
MJKelly MJKelly is offline
external usenet poster
 
Posts: 114
Default Offsetting to identify value in header row



Hi,

The code below is attempting to loop through a range of tasks (in a
single row) and once a task is found, offset a given number (negative)
of rows to capture the start time (which is in the header row) and
paste this value into another column on the origianal row. Then I
need the next row queried (the next job/person).

I just can't get it right, please help?

Sub AddStartTimes()

Dim R As Range
Dim ColOffset As Integer
Dim RowOffset As Integer
Dim C As Range

RowOffset = 1
ColOffset = 0


ThisWorkbook.Sheets("Monday").Select
For Each R In Range("D4:D1000")
For Each C In Range("H4").Offset(RowOffset,
0).Range("EU4").Offset(RowOffset, 0)
If Not C.Value = "" Then
R.Value = C.Offset(0 - RowOffset, 0).Value
Exit For
Else
ColOffset = ColOffset + 1
End If
Next C

RowOffset = RowOffset + 1
Next R


End Sub