How to Quickly Split One Contact Group into Two Groups via Outlook VBA

Many users ask for a quick approach to split a too large contact group, instead of copying and removing members manually. This article will teach how to use VBA to split a contact group into two groups in one click.

Perhaps you have a pretty large contact group in your Outlook. More specifically, this contact group has multiple members. In such cases, you may feel it a bit hard to organize them. Therefore, you may wish to split it. Usually, you can split by the method introduced in my older article – “How to Split a Large Outlook Contact Group”. But that means is too troublesome. Therefore, here we will introduce the second method, which can split a group into two in a jiffy.

Quickly Split One Contact Group into Two Groups via Outlook VBA

Quickly Split One Contact Group into Two Groups

  1. For a start, launch your Outlook program.
  2. Then in the Outlook main window, tap “Alt + F11” keys to access VBA editor.
  3. Next, in the “Microsoft Visual Basic for Applications” window, you need open an unused module.
  4. Subsequently, you have to copy the following VBA code into this module.
Sub SplitOneContactGroupIntoTwo()
    Dim objSourceContactGroup As Outlook.DistListItem
    Dim lMemberCount As Long
    Dim objNewContactGroup As Outlook.DistListItem
    Dim objMember As Outlook.recipient
    Dim objTempMail As Outlook.MailItem
 
    'Get the source contact group
    Select Case Application.ActiveWindow.Class
           Case olExplorer
                Set objSourceContactGroup = ActiveExplorer.Selection.Item(1)
           Case olInspector
                Set objSourceContactGroup = ActiveInspector.CurrentItem
    End Select
 
    'Create a new contact group
    Set objNewContactGroup = Application.CreateItem(olDistributionListItem)

    lMemberCount = objSourceContactGroup.MemberCount
 
    For i = 1 To objSourceContactGroup.MemberCount
        Set objMember = objSourceContactGroup.GetMember(i)
 
        'Remove the a certain amount of members from the source group
        'And add them to the new group
        If i < lMemberCount / 2 Then
           Set objTempMail = Application.CreateItem(olMailItem)
           objTempMail.Recipients.Add (objMember.Address)
 
           objNewContactGroup.AddMembers objTempMail.Recipients
           objSourceContactGroup.RemoveMember objMember
           objSourceContactGroup.Save
 
           objTempMail.Close olDiscard
        End If
    Next
  
    objNewContactGroup.Display
End Sub

VBA Code - Quickly Split One Contact Group into Two Groups

  1. After that, you could exit the current window by hitting the “X” icon in the upper right corner.
  2. Later, for future handy access, you are better off adding the new VBA project to Quick Access Toolbar, which can be completed in “Outlook Options”.
  3. Eventually, you can take a shot:
  • Firstly, you can select or open a contact group to be separated.
  • Then, hit the newly added macro button in the Quick Access Toolbar.
  • At once, Outlook will move about half of the original group’s members to the new contact group.

Resort to a Potent Fix Tool in Case of Outlook Corruption

Although Outlook boasts of multiple functions, it still cannot be free of errors and crashes. Generally, in the event of serious crash, Outlook data will be prone to get corrupted. Thus, it comes backed with an internal repair tool, Scanpst. However, if your PST file is compromised severely, the tool will not be helpful. Therefore, it is always recommended to keep a more robust tool nearby, such as DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf recovery and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.