473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need some For Loop Next Item

Hereis some basic code that works fine:

For Each itm In fld.Items
I = I + 1
j = 1

Set rng = wks.Cells(I, j)
If itm.Start <"" Then rng.Value = itm.Start
j = j + 1

Set rng = wks.Cells(I, j)
If itm.Subject <"" Then rng.Value = itm.Subject
j = j + 1

Next itm

here are what the vars are defined as:
Dim wks As Excel.Worksheet
Dim rng As Excel.Range
Dim I As Integer
Dim j As Integer
Dim lngCount As Long
' lngCount = fld.Items.Count somewhere else in the code
Dim nms As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Basically there are 19,000 items in the folder and I only need the
first 1000 or so. I ran it for the 19k and it took a few minutes, but
I need to do this every week. I tried a simple 1 to 1000 for loop but
it didn't work (probably because i'm an idiot). Other than clearing
out the 18k things I don't need, (because it's a public folder every
uses), How can I tell this for loop to only take the first 1000 or so,
or better yet to stop at a date! (itm.start is in microsoft date format
#)

Dec 15 '06 #1
2 1508
Kristopher,

Why not make it simple a for index loop.

For i as integer = 1 to 1000
do something to fld.items(i)
Next

Cor

<kr*****************@gmail.comschreef in bericht
news:11********************@79g2000cws.googlegroup s.com...
Hereis some basic code that works fine:

For Each itm In fld.Items
I = I + 1
j = 1

Set rng = wks.Cells(I, j)
If itm.Start <"" Then rng.Value = itm.Start
j = j + 1

Set rng = wks.Cells(I, j)
If itm.Subject <"" Then rng.Value = itm.Subject
j = j + 1

Next itm

here are what the vars are defined as:
Dim wks As Excel.Worksheet
Dim rng As Excel.Range
Dim I As Integer
Dim j As Integer
Dim lngCount As Long
' lngCount = fld.Items.Count somewhere else in the code
Dim nms As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Basically there are 19,000 items in the folder and I only need the
first 1000 or so. I ran it for the 19k and it took a few minutes, but
I need to do this every week. I tried a simple 1 to 1000 for loop but
it didn't work (probably because i'm an idiot). Other than clearing
out the 18k things I don't need, (because it's a public folder every
uses), How can I tell this for loop to only take the first 1000 or so,
or better yet to stop at a date! (itm.start is in microsoft date format
#)

Dec 16 '06 #2
Ohh, You know I saw somewhere something like fld.items(i) in another
example, and I thought maybe I could make an array out of the items in
the folder, but I don't know the syntax of VBA, because i'm just
figuring it out by trial an error.

I'll give it a shot. Maybe try to set a control var for the date.

Thanks
On Dec 16, 4:25 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Kristopher,

Why not make it simple a for index loop.

For i as integer = 1 to 1000
do something to fld.items(i)
Next

Cor

<kristopher.erick...@gmail.comschreef in berichtnews:11********************@79g2000cws.goog legroups.com...
Hereis some basic code that works fine:
For Each itm In fld.Items
I = I + 1
j = 1
Set rng = wks.Cells(I, j)
If itm.Start <"" Then rng.Value = itm.Start
j = j + 1
Set rng = wks.Cells(I, j)
If itm.Subject <"" Then rng.Value = itm.Subject
j = j + 1
Next itm
here are what the vars are defined as:
Dim wks As Excel.Worksheet
Dim rng As Excel.Range
Dim I As Integer
Dim j As Integer
Dim lngCount As Long
' lngCount = fld.Items.Count somewhere else in the code
Dim nms As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim itm As Object
Basically there are 19,000 items in the folder and I only need the
first 1000 or so. I ran it for the 19k and it took a few minutes, but
I need to do this every week. I tried a simple 1 to 1000 for loop but
it didn't work (probably because i'm an idiot). Other than clearing
out the 18k things I don't need, (because it's a public folder every
uses), How can I tell this for loop to only take the first 1000 or so,
or better yet to stop at a date! (itm.start is in microsoft date format
#)- Hide quoted text -- Show quoted text -
Dec 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jason | last post by:
Access 2000: I have a customer-inventory table I need to loop through and compile a list of all the inventory items the customer is tracking. The problem I am finding is that a simple loop...
11
by: William Payne | last post by:
Ok, in my program I have a std::list<Document*>, where Document is one of my own classes. I need to go through this list and check each item if it's ready for deletion. If it's not, skip to...
3
by: giant food | last post by:
This seems like a long shot, but I wondered if there's a way to loop over the values in an Enum. For example, say I have an Enum as follows: Public Enum statusValues Ready Running Finished...
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
3
by: Matt | last post by:
I am in the process of creating a custom .NET object (this is my first one). I have created a few classes and some of them are collections. When I try to iterate through a collection I receive the...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
10
by: preethamkumark | last post by:
- The program first creates a shared memory buffer containing an array of 20 integers. - Each slot of the buffer can have either 0 or 1, where 0 represents an empty slot, and 1 represents an...
0
by: south622 | last post by:
I'm taking a beginning Java course and I'm stuck in week eight of a nine week course. If anyone could help me I would greatly appreciate it. This assignment was due yesterday and each day I go past...
14
by: David | last post by:
Hi, I have a form on which a user can select a checkbox against a record. Each checkbox carries the RecordID of a product. ---------------------------------------------------------------- I...
16
by: Andy B | last post by:
I have the following code inside of a WebBrowser.DocumentCompleted event: For index As Integer = 0 To Me.Browser.Document.GetElementsByTagName("ul").Item(0).GetElementsByTagName("li").Count ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.