![]() |
moving thru a noncontiguous range
Hello
on sheet1 i have 24 columns 12 of which represent the months of the year with the adjacent column containg containing either a letter D or N, denoting wether a day or night shift is worked on particular date. how can i best represent this in VBA so that i can 'loop' thru each day of each month and look across to the adjacent column to see what shift is worked. regards San |
moving thru a noncontiguous range
maybe something like this. i assumed jan was in a and jan 1st - 31 was in row
2 - 32 Sub test() Dim i As Long, z As Long z = 1 For i = 1 To 24 Step 2 For z = 2 To 32 If UCase(Cells(z, i).Offset(, 1).Value) = "N" Then MsgBox "found N" ElseIf UCase(Cells(z, i).Offset(, 1).Value) = "D" Then MsgBox "found D" End If Next Next z = z + 1 End Sub -- Gary wrote in message oups.com... Hello on sheet1 i have 24 columns 12 of which represent the months of the year with the adjacent column containg containing either a letter D or N, denoting wether a day or night shift is worked on particular date. how can i best represent this in VBA so that i can 'loop' thru each day of each month and look across to the adjacent column to see what shift is worked. regards San |
moving thru a noncontiguous range
Gary Keramidas wrote: maybe something like this. i assumed jan was in a and jan 1st - 31 was in row 2 - 32 Sub test() Dim i As Long, z As Long z = 1 For i = 1 To 24 Step 2 For z = 2 To 32 If UCase(Cells(z, i).Offset(, 1).Value) = "N" Then MsgBox "found N" ElseIf UCase(Cells(z, i).Offset(, 1).Value) = "D" Then MsgBox "found D" End If Next Next z = z + 1 End Sub -- Gary wrote in message oups.com... Hello on sheet1 i have 24 columns 12 of which represent the months of the year with the adjacent column containg containing either a letter D or N, denoting wether a day or night shift is worked on particular date. how can i best represent this in VBA so that i can 'loop' thru each day of each month and look across to the adjacent column to see what shift is worked. regards San Thanks Gary worked perfectly San |
moving thru a noncontiguous range
you're welcome, glad it did what you needed. had an extraneous z=1 in my code,
but it shouldn't hurt anything -- Gary wrote in message ups.com... Gary Keramidas wrote: maybe something like this. i assumed jan was in a and jan 1st - 31 was in row 2 - 32 Sub test() Dim i As Long, z As Long z = 1 For i = 1 To 24 Step 2 For z = 2 To 32 If UCase(Cells(z, i).Offset(, 1).Value) = "N" Then MsgBox "found N" ElseIf UCase(Cells(z, i).Offset(, 1).Value) = "D" Then MsgBox "found D" End If Next Next z = z + 1 End Sub -- Gary wrote in message oups.com... Hello on sheet1 i have 24 columns 12 of which represent the months of the year with the adjacent column containg containing either a letter D or N, denoting wether a day or night shift is worked on particular date. how can i best represent this in VBA so that i can 'loop' thru each day of each month and look across to the adjacent column to see what shift is worked. regards San Thanks Gary worked perfectly San |
All times are GMT +1. The time now is 06:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com