Consulting

Results 1 to 2 of 2

Thread: Categories Help

  1. #1
    VBAX Newbie
    Joined
    May 2014
    Posts
    2
    Location

    Categories Help

    Hi all,

    I have been slowly learning VBA in Excel when I get the free time, but this is my first venture into Outlook.

    I currently have set up Categories for priority. Eg. 1st Priority, 2nd Priority, 3rd Priority and so on up to 10th, and a category for not sorted emails. Is there a way that I can run a macro to change the priority up one (eg. 2nd now becomes 1st) as I deal with the 1st emails. If so, could some one please help me in the direction of a tutorial or code and some explanation of the code.

    Thanks in advance.

  2. #2
    you can test this to see if it does as you want
    Dim myitem As MailItem, f As MAPIFolder
    Set f = ActiveExplorer.CurrentFolder
    For Each myitem In f.Items
        cats = Split(myitem.Categories, ",")
        For i = 0 To UBound(cats)
            If InStr(cats(i), "Priority") > 0 Then
                Select Case Split(cats(i))(0)
                    Case "2nd": Split(cats(i))(0) = "1st"
                    Case "3rd": Split(cats(i))(0) = "2nd"
                    Case "4th": Split(cats(i))(0) = "3rd"
                    Case Else: cats(i) = Val(cats(i)) - 1 & Mid(cats(i), 1 + Len(CStr(Val(cats(i)))))
                End Select
                
            End If
        Next
        myitem.Categories = Join(cats, ",")
    Next
    runs without error, but results untested

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •