View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_17_] Leith Ross[_17_] is offline
external usenet poster
 
Posts: 1
Default Find ranges of rows that contain 1


Hello Admanirv,

This code does what you want. It starts at "B2" looking for a 1 in tha
column. If a I is present it will build the days worked string a
outlined. The string will then be stored starting at "F2", then "G2"
etc.


Code
-------------------
Public Sub FindOpDays()

Dim N, D
Dim I As Long
Dim LastRow As Long
Dim FirstDay As Integer

LastRow = Range(\"A65536\").End(xlUp).Row

For I = 2 To LastRow
N = Cells(I, \"B\").Value
D = Cells(I, \"A\").Value
If N = 1 Then
If FirstDay = 0 Then FirstDay = D
Else
If FirstDay < 0 Then
Cells(2, \"D\").Offset(0, I).Value = Trim(Str(FirstDay)) &\" - \" & Trim(Str(D))
FirstDay = 0
End If
End If
Next I

End Su
-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=37411