Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2019, 07:28 AM
ThinAirDesigns ThinAirDesigns is offline Looping backwards through a 'For Each' collection Windows 10 Looping backwards through a 'For Each' collection Office 2003
Novice
Looping backwards through a 'For Each' collection
 
Join Date: Sep 2018
Posts: 5
ThinAirDesigns is on a distinguished road
Default Looping backwards through a 'For Each' collection

Here is the usual VBA code for looping through all tasks in Projects:



For Each t In ActiveProject.Tasks
{code for desired action}
Next t

This loops through from the top down (as far as I can tell).

Anyone have any ideas as to how I can reverse this and go from the bottom up?

Thanks
JB
Reply With Quote
  #2  
Old 05-02-2019, 02:16 PM
ThinAirDesigns ThinAirDesigns is offline Looping backwards through a 'For Each' collection Windows 10 Looping backwards through a 'For Each' collection Office 2003
Novice
Looping backwards through a 'For Each' collection
 
Join Date: Sep 2018
Posts: 5
ThinAirDesigns is on a distinguished road
Default

Solved (with all credit to Tom Boyle)

Sub BackTasks()
Dim t As Task

Dim i As Long

For i = ActiveProject.Tasks.Count To 1 Step -1

Set t = ActiveProject.Tasks(i)

If Not t Is Nothing Then

'Your Code Here

End If

Next i

End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
site collection is inaccurate dbsoccer51 Misc 0 12-02-2015 03:30 PM
Looping backwards through a 'For Each' collection Upgrading backwards !!! Soporose Office 1 09-23-2014 02:04 AM
Looping backwards through a 'For Each' collection how to calculate backwards from a set finish date ketanco Project 1 02-07-2013 06:50 AM
Looping backwards through a 'For Each' collection Backwards Searching Using a Formula OTPM Excel 5 05-17-2011 09:17 AM
Visio 2002 backwards compatible with 2000 franklyorange Visio 0 11-17-2008 11:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft