+ Reply to Thread
Results 1 to 23 of 23

[VBA request] Select first entry of todays date + last row of a column and copy/paste?

  1. #1
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Hey team! Sorry for the confusing title, my tiny brain cant figure out how to word it. Thank you for reading as well! I see a ton of activity here which is insane. I dont know how some of you guys rip through answers so quickly all day :D :D

    TLDR: I have varying dates in column A and need to identify the first entry with todays date and select everything else to the bottom-right/end of the table. Is this possible in VBA?

    Anyway so what I have is a table that auto fills based on user emails and its listed by date. The latest entry auto adds to the table as a new row in it. At the end of the day I copy all of this info into a cell of a different sheet which has some VBA and formulas to auto pull info from it to create a presentable email of stats for the day. I want to basically make it so literally all I have to do is download a local copy of the Excel web file, click a button and it does the rest. So I just have to automate the last bit.

    Is it possible to make a VBA script that identifies the first column A date cell based on today, then copy everything from that cell in column A, to the very last existing row in, say, column C or whatever. The nature of these entries being done by users means that sometimes when users forget to submit their entries, they wait for the next day and mark the "current date" as yesterday, so technically I cannot rely on each row having todays date exclusively. I've seen up to 5 days old so this is why I was thinking it would be awesome if you could just grab the first cell of todays date, and finish up the range, copy, and paste in a different sheet.

    The pasting and switching to sheet bit I can do, I just dont know how I could grab the range based on this issue. Does that make sense?

    Here is a screenshot (just a dummy)

    Screen Shot 2021-12-28 at 1.14.22 PM.png

    Edit: Issue is solved

    My end result is this code, which from a different sheet selects all cells from the first entry containing todays date, down to the last row of a specified amount of columns, copies the info, and pastes into a cell from another different sheet

    Please Login or Register  to view this content.
    Last edited by mvfsullivan; 12-30-2021 at 06:28 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    crossposted: https://www.mrexcel.com/board/thread...olumn.1191333/

    Rule 03: Cross-posting Without Telling Us

    Your post does not comply with Rule 3 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Read this to understand why we ask you to do this.

    I have added the crosspost reference for you today. Please comply with this and all our rules in the future
    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

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Hi and welcome to the forum

    Here's one way:
    Please Login or Register  to view this content.
    See attached.

    There may be a little tinkering required depending on your data layout, but we can help with that .

    BSB
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    I ended up messaging a mod to delete that post and they are yet to reply. Please disregard that post! I searched everywhere and found that "ExcelForum.com" is the best single source so I am staying here. Sorry about that!

  5. #5
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Hmm I'm unable to get even the original file you uploaded to work. It selects the range?

    Can you have the button click another reference table and paste the info? I'm sorry I'm very new to VBA

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by mvfsullivan View Post
    The pasting and switching to sheet bit I can do, I just dont know how I could grab the range based on this issue.
    This bit in your original post lead me to believe you just wanted code to select the range and you knew how to copy it and paste it elsewhere.

    Is the table you want it pasted to on the same sheet or another?
    Is there already data in that table or is it empty?
    If already data in there, do you just want this data tagged on the end or the previous data cleared then pasted in?

    BSB

  7. #7
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    I thought I knew what I was doing but I guess not

    I've exclusively been experimenting in that file you made, baby steps you know!

    I thought your code would visually select the relative cells and then I would just add the "Selection.Copy" and Range("xxx").Select
    ActiveSheet.Paste

    It doesnt work

    I intend on leaving the original selection there, just copying the info and pasting in a cell (and yes it will be in a different sheet)

    Thank you very much for helping me btw!!
    Attached Images Attached Images
    Last edited by mvfsullivan; 12-28-2021 at 04:05 PM.

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Try this version:
    Please Login or Register  to view this content.
    BSB
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    That looks great, thank you for this BSB :D! When I click the Click Me button it highlights the same row in the screenshot, where the .Range(r.Row,1) is, saying error 91. Is this something on my end? I am using Mac OS, latest Excel version

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    I'm afraid I cannot comment on the error. Doesn't throw up an error for me and I cannot test it on MacOS as I'm PC based only.

    Does the error show up when you click the button in the version attached to post #8?

    BSB

  11. #11
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    I still need help with this. Anyone else have any suggestions?

    BSB is helping me via DM and is getting some well deserved shut eye lol :D

    P.S. It refused to allow me to post until now!

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Try
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15
    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    Edit: Woah it actually worked when I tried just now on the next day. I didnt even change anything. Maybe it was something unrelated and the shutdown / restart fixed the issue? My god I have no clue what just happened and why it works now lol

    It doesnt work with a dev button but if I make my own via shape, it works
    Attached Images Attached Images
    Last edited by mvfsullivan; 12-29-2021 at 03:57 PM.

  14. #14
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    Hey! This works great, but is there a way to activate this from another sheet? I want to be able to set the button in a dedicated sheet and grab from the original (sheet 1) and paste in the current sheet where the button will be (sheet 2)

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Try change to
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by jindon View Post
    Try change to
    Please Login or Register  to view this content.
    Omg you are amazing haha. One last thing I think and all will be good. Sorry I didnt realize my actual real file would be such a fuss.

    When I add this info into my real file, it turns out that the other tables that rely on the copied info seems to show a #value! error in the cell. I think it may have something to do with the fact that the actual column I rely on is A:S. Is there a way your script can specifically end on the last row but stop at column S instead of going through every column in the table?

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by jindon View Post
    Try change to
    Please Login or Register  to view this content.
    Oh wait when I use this code it shows error 9 on the With Sheets line

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by mvfsullivan View Post
    grab from the original (sheet 1) and paste in the current sheet where the button will be (sheet 2)
    Change Sheet1 to Sheet 1

  20. #20
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by jindon View Post
    Change Sheet1 to Sheet 1
    Damn, same error on the same line.

    I removed all modules, force quit Excel, reopened the macro enabled workbook, created a button > assign macro > new > replaced everything with your code, added a space and saved/closed VBA, then clicked the button and I get error 9. Debug shows the With Sheets line as yellow

    Edit: I just had to use the actual sheet name, "Tracker" Good to go!
    Last edited by mvfsullivan; 12-29-2021 at 09:39 PM.

  21. #21
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by jindon View Post
    Change Sheet1 to Sheet 1
    You are freakin awesome.

    I DM'd you asking a question, before you go ahead and answer this. The initial thread question has been solved!!

    -

    Ok everything is working in regards to selecting what I need and pasting where I need it to be pasted, but for some reason if I manually paste this info in the target table, the other table which references each row, cell by cell does fill properly, but the next table that searches a word based on the reference table info shows #value!. Does that make sense? and do you know what could possibly cause this?

    Its a bit hard to explain so here is a screenshot of what my actual table is:

    Empty table - This is without anything entered in B4 (where the table starts):
    Attachment 761336

    Manually pasted info into B4:
    Attachment 761337

    Auto filled based on your code, automatically entered into B4:
    Screen-Shot-2021-12-29-at-8-57-26-PM.png
    Last edited by mvfsullivan; 12-29-2021 at 10:05 PM.

  22. #22
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Your attachments are all invalid.

    Upload a workbook that you are working with.

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  23. #23
    Registered User
    Join Date
    12-16-2021
    Location
    Canada
    MS-Off Ver
    16.56 (21121100)
    Posts
    15

    Re: [VBA request] Select first entry of todays date + last row of a column and copy/paste?

    Quote Originally Posted by jindon View Post
    Your attachments are all invalid.

    Upload a workbook that you are working with.

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Hey! I just realized that the script does everything I need unless something in the table has an # error in it. Is this fixable?

    Edit: Nvm this issue went away when I set a column count
    Attached Images Attached Images
    Last edited by mvfsullivan; 12-30-2021 at 06:25 PM.

+ 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. date column to look up todays date and copy/paste in same row as date lookup
    By fst100 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2019, 07:48 AM
  2. [SOLVED] Copy,Cut, Paste Row to different sheet when date entered becomes todays date - Please Help
    By Mykull in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-11-2016, 01:55 PM
  3. [SOLVED] Finding todays date in column A then select adjacent cell
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-03-2016, 10:50 AM
  4. VBA Code to select column based on a date then perform copy/paste and shade
    By tompee29 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2014, 06:25 AM
  5. Copy/paste row with todays date in Sheet2 to sheet 3....but from Sheet 1
    By cammyjane10 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-25-2013, 01:07 PM
  6. copy and paste into todays column
    By guerillaexcel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2010, 04:23 AM
  7. Automatic entry of todays date
    By maverick911 in forum Excel General
    Replies: 1
    Last Post: 11-21-2007, 05:34 AM

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