Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Noncontiguous cell range jeffrey Excel Worksheet Functions 1 June 15th 11 06:27 PM
Noncontiguous rows KC8DCN Excel Discussion (Misc queries) 3 August 18th 06 05:34 AM
noncontiguous cells Vivian Excel Discussion (Misc queries) 2 July 21st 06 01:00 AM
sum with moving range snax500 Excel Discussion (Misc queries) 3 July 10th 06 05:56 AM
NonContiguous Range Iteration Bug? Matthew Wieder Excel Programming 5 March 3rd 04 04:58 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"