ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filling a table based on header row name (https://www.excelbanter.com/excel-programming/418083-filling-table-based-header-row-name.html)

MJKelly

filling a table based on header row name
 
Hi,

Can you help me with the code below?
I'm trying to fill a status taken from column b and put it in a table
in between two time values. the first time value is c.offset(0,1) and
the second is c.offset(0,2). In the table the times are held in row
1. The status will be sick or holiday etc, if the person is at work
they have a numeric duty code hence the isnumeric check. Once the
status has been filled to the time window, the next "c" in the range
is checked.

For Each c In Sheets("Staff Monday").Range("B2:B100")
isDuty = IsNumeric(c.Value)
If isDuty = False Then
Status = c.Value
For Each r In Range(c.Offset(0, 5), c.Offset(0, 148))
If Cells(1, r.Column).Value = c.Offset(0, 1) Then
r.Value = Status

Do Until Cells(1, r.Column).Value = c.Offset(0, 2).Value
r.Offset(0, MyOffset).Value = Status
MyOffset = MyOffset + 1
Loop
End If


Next r
End If
Next c

regards,
Matt

Barb Reinhardt

filling a table based on header row name
 
See answer in other post.

"MJKelly" wrote:

Hi,

Can you help me with the code below?
I'm trying to fill a status taken from column b and put it in a table
in between two time values. the first time value is c.offset(0,1) and
the second is c.offset(0,2). In the table the times are held in row
1. The status will be sick or holiday etc, if the person is at work
they have a numeric duty code hence the isnumeric check. Once the
status has been filled to the time window, the next "c" in the range
is checked.

For Each c In Sheets("Staff Monday").Range("B2:B100")
isDuty = IsNumeric(c.Value)
If isDuty = False Then
Status = c.Value
For Each r In Range(c.Offset(0, 5), c.Offset(0, 148))
If Cells(1, r.Column).Value = c.Offset(0, 1) Then
r.Value = Status

Do Until Cells(1, r.Column).Value = c.Offset(0, 2).Value
r.Offset(0, MyOffset).Value = Status
MyOffset = MyOffset + 1
Loop
End If


Next r
End If
Next c

regards,
Matt



All times are GMT +1. The time now is 09:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com