
Set OutlookNamespace = OutlookApp.GetNamespace(“MAPI”) Set Folder = Session.Folders(strMailboxName) StrMailboxName = “Internal Team 1” ‘name of shared inbox Hi There, I know im kinda late on this thread, but i stumbled across your macro, and i found a way to use this with a shared inbox/folder. It’s a pretty simple VBA procedure, but it can be very useful if you have to deal with a lot of similar emails. Range("eMail_text").Offset(i, 0).Value = OutlookMail.Body Range("eMail_sender").Offset(i, 0).Value = OutlookMail.SenderName Range("eMail_date").Offset(i, 0).Value = OutlookMail.ReceivedTime Range("eMail_subject").Offset(i, 0).Value = OutlookMail.Subject If OutlookMail.ReceivedTime >= Range("From_date").Value Then Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("Net Sales Report").Folders("Sales")

Set OutlookNamespace = OutlookApp.GetNamespace("MAPI") The main text body from emails will be imported just below this cell.

Subjects from emails will be imported just below this cell.
#Import data from excel to excel vba code
These are the named ranges the code will use. I have added named ranges to the workbook as referring to a cell with a named range in VBA rather than the generic cell address such as Range(“A1”) means you can move things around in your workbook without worrying about breaking your code. Folders(“Subfolder Name”) onto the Set Folder = line of code. If you wanted to import from a subfolder of Sales then you would need to append another.

In this example I’m going to be importing from an Outlook folder called Inbox/Net Sales Report/Sales. In the visual basic editor, go to Tools then References and check the box next to it and press OK button to enable it.
#Import data from excel to excel vba how to
If you’re unfamiliar with VBA, then it’s probably a good idea to read this post about How To Use The VBA Code You Find Online before continuing reading and working with the completed workbook.įor this code you will need the Microsoft Outlook 16.0 Object Library enabled.
