Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

VBA for MS Project, loop in Selected Range

$
0
0

Hello friendly experts!

I've been having a wonderful time putting your combined advice through these threads to use.

I've come a little un-stuck trying to adapt a macro I use for looping through the entire project on only the selected range.

I'm concerned that perhaps this isn't possible. Dale Howard of MSP fame on the Microsoft forums alludes to this in his post here: http://answers.microsoft.com/en-us/office/forum/office_2003-project/when-i-highlight-and-sort-some-tasks-the-entire/f04d645a-a150-e011-8dfc-68b599b31bf5

(Sorry, they won't let me link until my account is verified. Which I haven't figured out how to do!)

So far I've discovered that i cannot "Dim Rng As Range" because "As Range" doesn't exist!!!

This is what I have tried:

Sub HighlightNightsSelected()

Dim t As Task
Dim SubProjId As Long
Dim TskSub As Task

    For Each t In ActiveSelection.Tasks

        If Not t Is Nothing Then
            If t.Subproject <> "" Then
                SubProjId = t.ID
            ElseIf Not t.Summary Then
                SelectRow Row:=SubProjId + t.ID, rowrelative:=False
                Select Case t.Calendar
                    Case "Night Shift"
                        Font32Ex CellColor:=12611584
                    Case "Standard"
                        Font32Ex CellColor:=13036780
                    Case "None"
                        Font32Ex CellColor:=-16777216
                End Select
            End If
        End If
    Next t
    EditGoTo ID:=1
End Sub

Surely I'm missing a trick?



Viewing all articles
Browse latest Browse all 2257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>