LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default For Each and Collections

Hello Guys,

This one needs a new thread I think. I have a range(G5:G19) with following
values: "christmas", "newyear", "easter", etc.. another range (H5:H19) with
the values (or keys as i assume) "25 dec", "1 jan", "9 apr", etc... these key
values are a customized date datatype "d mmm", as you can see.

So in my code i defined two ranges, and i add the values and the keys to the
collection. Next I try to use a For Each... Next to be able to do something
for each item in the collection, and that's where it goes wrong.

The keys in the collection are the dates, but when i use my function, it
doesn't do anything on christmas, easter, or any other holiday... i get no
errors whatsoever anymore, so the code seem to be okay... So i'm kinda lost
here, no errors, no nothing... i've actually tried several other values (such
as dates), to change the datatype in the ranges, and than a #VALUE pops up in
the field where i use the "TOEF" function, so that seems to be working okay..

Any ideas here?

Function Toef(sDate As Date, bNPrestaties As Integer, vCode As String,
uitVM, _
inVM, uitNM, inNM, NaR, CAD As Single)
Dim hCollection As Collection
Dim hCItemCounter As Long
Dim hCItem As Variant
Dim hColRange As Range
Dim hKeyRange As Range
Set hColRange = Worksheets("CODE").Range("G5:G19")
Set hKeyRange = Worksheets("CODE").Range("H5:H19")
Set hCollection = New Collection
For hCItemCounter = 1 To 15
hCollection.Add Item:=hColRange.Cells(hCItemCounter).Value, _
Key:=CStr(hKeyRange.Cells(hCItemCounter).Value)
Next hCItemCounter
For Each hCItem In hCollection
If hCItem = sDate Then
Toef = (uitVM - inVM) + (uitNM - inNM) + NaR + CAD
Else
Toef = ""
End If
Next hCItem


 
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
Listbox and Collections (Again!) John[_88_] Excel Programming 3 September 9th 05 02:33 PM
newbie needs help with collections rozner[_2_] Excel Programming 2 August 2nd 05 01:46 PM
Collections of Collections David Morton Excel Programming 6 November 13th 04 01:10 AM
Help with collections ksnapp[_45_] Excel Programming 1 April 7th 04 12:42 AM
Using Collections Kerry[_4_] Excel Programming 1 January 25th 04 04:08 PM


All times are GMT +1. The time now is 02:04 AM.

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

About Us

"It's about Microsoft Excel"