Insert a ghost entry to a collection

K

ksnapp

Hi,

This code works great with one exception. Here is the code:

Sub hope_fully()

Dim days As New Collection
Dim data As New Collection
Dim collen As New Collection
Dim TR As Single
Dim SR As Single
Dim rnghold As Range
Dim rng As Range
Dim daysCNT As Single
Dim findme As Variant
Dim i As Single
Dim j As Single
Dim LN As Single
Dim found As Variant
Dim y As Single

Workbooks("Book2.xls").Activate

With Selection
daysCNT = Selection.Columns.Count
Set rnghold = Selection
For Each cell In rnghold
days.Add (cell)
Next
End With
MsgBox daysCNT

With days

For i = 1 To daysCNT Step 1
Workbooks("Book1.xls").Activate
Worksheets(days(i)).Select
TR = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("a1", Cells(TR / 2, 1))
With rng
findme = "7:30"
.Find(what:=findme, LookIn:=xlValues).Select
On Error Resume Next
findme = "7:00"
.Find(what:=findme, LookIn:=xlValues).Select
SR = Selection.Row
data.Add (Range(Cells(SR, 6), Cells(TR, 6)))
LN = TR - SR
collen.Add (LN)
End With

MsgBox SR
Next i

The problem relates to the find me section. first they're in tha
order cause All records contain a 7:30, but not all contain 7:00.
the way this sub inserts the data in book2 puts the starting point al
in the same row regardles of if the record started at 7:30 or 7:00.

my solution is to put a zero(0) in the beging of the data collectio
when the record starts and 7:30 (no 7:00 found). The problem is
don't know how.

any help or other ideas are appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top