+ Reply to Thread
Results 1 to 5 of 5

Pulling todays records from a table

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Pulling todays records from a table

    My brain is telling me that this ought to be simple. But..... it aint working.

    table1 has three columns DATE, TRANS CODE, NOTE.

    table 1 has a few thousand rows. On any given day we do anywhere from one to a hundred transactions. So, as a courtesy I'd like to quickly pull todays transactions and send only those rows in an email. I was thinking that if I could extract todays transactions and have them appear on a separate tab I could just copy/paste into outlook. But I cannot find an easy way to do it. If it was msaccess I would write a query and be done with it. But, alas, we got to work with what we have.

    What have I overlooked?

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,887

    Re: Pulling todays records from a table

    Why not filter on Today's date, copy and paste to new tab?

  3. #3
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Re: Pulling todays records from a table

    Wow that was fast :-)

    I'm doing exactly that right now. I have another guy that inputs into the main data page who isn't spreadsheet friendly. The separate tab idea was mainly to allow him to do what I am doing without any further complications. He's a great guy. But his excel skills are limited to typing, hit tab to go to the next cell, type, hit enter.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: Pulling todays records from a table

    Here is some untested VBA code that should help

    Option Explicit
    
    Sub TodayTrans()
        Dim lr As Long, i As Long
        Dim s1 As Worksheet, s2 As Worksheet
        Set s1 = Sheets("Sheet1")
        Set s2 = Sheets("Sheet2")
        lr = s1.Range("A" & Rows.Count).End(xlUp).Row
        Application.ScreenUpdating = False
        lr2 = s2.Range("A" & Rows.Count).End(xlUp).Row
        s2.Range("A2:C" & lr2).ClearContents
        With s1
            For i = 2 To lr
                lr2 = s2.Range("A" & Rows.Count).End(xlUp).Row
                If .Range("A" & i).Value = Date Then
                    .Range("A" & i & ":C" & i).Copy s2.Range("A" & lr2 + 1)
                End If
            Next i
        End With
        Application.CutCopyMode = False
        Application.ScreenUpdating = True
        MsgBox ("Ready to email")
    End Sub
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button



    EDIT: I think that John's solution will run faster.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,887

    Re: Pulling todays records from a table

    By tab I mean sheet! Confused by your response!!

    Select all Today's transaction in Sheet1, copy and paste to Sheet2.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pulling records matching two criteria and inserting those records into an existing list
    By desertfx41 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2014, 02:00 PM
  2. [SOLVED] Pulling Aggregate Data from Table 1 to Automate Drawing Conclusions from Table 2
    By QuantumPolagnus in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-11-2013, 05:14 PM
  3. [SOLVED] Pulling out the latest records ONLY. VBA
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 12-13-2012, 11:42 AM
  4. [SOLVED] Index(match not pulling only 2 of five records
    By mmayna03 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-25-2012, 10:45 AM
  5. My formula is pulling all multiple records except the first one found
    By jshumberger25 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-24-2012, 03:36 PM
  6. [SOLVED] pulling unique records from one workbook to another
    By paintballlovr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-15-2012, 03:10 PM
  7. Print todays Report using todays date
    By jerryjaysr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2007, 04:09 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1