Creating a Queue in Excel

ryanl1204

New Member
Joined
Oct 21, 2013
Messages
2
I'm brand new to VBA and I don't really know what I'm doing yet. I searched google to find a way to create a queue system in excel.

Here is what I would like to do:

Pull emails from outlook into a spreadsheet and click an add button that would add the From and Subject of the email to the bottom of the list with a timestamp showing the time the add button was pressed for that email. I would like the list to have the oldest timestamps stay at the top of the list, if possible.

I would be more than happy to provide more detail if anyone is able to help.

Thanks.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Here's something rough which I have put together that you can adapt. You'll need to assign this procedure to a button. It assumes that you have your headers already in before you run for the first time.

It will pull in all emails received since the last time you pressed the button. It will place them in reverse order, but seeing as you aren't recording the received time, I assume that it doesn't matter. Lastly, you'll need to set a reference to the Outlook Object Library, to do this click on Tools>References and then choose Microsoft Outlook x.0 Object Library, where x represents the version number of Outlook.

Code:
Sub AddEmailDetails()

Dim outApp As Outlook.Application
Dim outItems As Outlook.Items
Dim i As Integer
Dim rng As Range
Dim dNow As Date


    dNow = Now
    Set outApp = Outlook.Application
    Set rng = Cells(Cells(1, 1).CurrentRegion.Rows.Count, 1)
    Set outItems = outApp.Session.GetDefaultFolder(olFolderInbox).Items.Restrict("[Received] > '" _
        & Format(rng.Offset(0, 2), "ddddd h:nn AMPM") & "'")


    For i = 1 To outItems.Count
        rng.Offset(i, 0) = outItems(1).Sender
        rng.Offset(i, 1) = outItems(1).Subject
        rng.Offset(i, 2) = dNow
    Next


Set outItems = Nothing
Set rng = Nothing
Set outApp = Nothing


End Sub

Chances are you'll probably get a warning from Outlook because you're accessing the Sender property. If this is the case and it isn't acceptable then ways of avoiding this include, but are not limited to:
  • changing this code so it sits in Outlook
  • downloading Redemption

Please amend this code to suit your needs. Hope this helps

Simon
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top