+ Reply to Thread
Results 1 to 7 of 7

Need to copy specific cells into an existing worksheet based on date entered by user

  1. #1
    Registered User
    Join Date
    09-30-2011
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Need to copy specific cells into an existing worksheet based on date entered by user

    Hi all,
    I am looking to gather data from Sheet (“NSF Log”) and copy it to Sheet (“Journal”) based on the date found in column “B” of Sheet (“NSF Log”). The intent is that using a command button, a message box will appear and the user can enter the date. The system will then look through column B of Sheet (“NSF Log”) to find the date and whenever there is a match, it will copy specific information on the corresponding rows as follows:

    "NSF Log” copy columns “O” to “V” and paste it to “Journal” starting on “C17”.
    “NSF Log” copy column “K” and paste it to “Journal” starting on “K17”.
    “NSF Log” copy column “A” and paste it to “Journal” starting on “M17”.

    Also, before copying the data to Sheet "Journal", I would like the system to erase any existing data from prior searches.

    I have included a copy of the excel spreadsheet with sample data.

    I don't know much about VBA, but any help is greatly appreciated!
    Attached Files Attached Files
    Last edited by jrfleury; 10-17-2011 at 09:47 AM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Need to copy specific cells into an existing worksheet based on date entered by u

    jrfleury,

    Something like this?
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    09-30-2011
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need to copy specific cells into an existing worksheet based on date entered by u

    Thanks for the quick response tigeravatar.

    Unfortunately it's not working 100%. When I run the code, the message box to enter the date pops up, but when I enter a date, ie 18-Sep-11, I get the message that it is an invalid date. I've tested it with other dates too, but the same message appears.

    I don't understand VBA code, so I'm not sure how to fix this.

    Any ideas?

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Need to copy specific cells into an existing worksheet based on date entered by u

    jrfleury,

    I think I missed keyword Set for rngResults, give this a try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-30-2011
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need to copy specific cells into an existing worksheet based on date entered by u

    That works perfectly!

    One last thing tho...when i lookup a date, say 18-Sep-11, the data copies over exactly as needed but when I do another search, say 21-Sep-11, I get an Run-time error 1004. I'm guessing this is because there is currently information in the cells in sheet "Journal". Is there a way to clear the existing data in the sheet "Journal" before the information is copied from sheet "NSF Log"?

    I truly appreciate all of your help!

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Need to copy specific cells into an existing worksheet based on date entered by u

    jrfleury,

    Updated code:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-30-2011
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need to copy specific cells into an existing worksheet based on date entered by u

    This works perfectly!!

    I wish I had a better understanding of VBA language so I could help other users as well.

    Thank you so much for your help. Much appreciated!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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