+ Reply to Thread
Results 1 to 10 of 10

Match Date and Copy Paste - Object Required Error

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Match Date and Copy Paste - Object Required Error

    Hey Everyone,

    This is my first post. I'm very new to VB, well coding in general, I did some C++ back in the day but that was it. I'm trying to Build a Macro that takes data from one worksheet and places it into the corresponding row of another worksheet which has the same initial date. I've gotten this far but I keep getting a Object Required Error for the line that reads If Today.Value = Range(A, i).Value Then. What I'm trying to say in this statement is that if the date from Daily Report matches the date in the specified A cell (i=1 to 700) then paste date in the cell Bi. This code is going to get a lot bigger but right I'm starting small to work towards something bigger. This is what I have so far. Any Advice would be great.


    Please Login or Register  to view this content.
    Last edited by ashleys.nl; 09-13-2011 at 12:15 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Match Date and Copy Paste - Object Required Error

    This
    Please Login or Register  to view this content.
    should either be
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Note that you don't need to select sheets. E.g.
    Please Login or Register  to view this content.
    is equivalent to
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Match Date and Copy Paste - Object Required Error

    THANK YOU SOOOOO MUCH! it was just a silly mistake but you've helped me with my project soo much! thank you ! Thank you.

    Here's the working code in case others run into this problem, I still have to clean up the ".Select"s but other than that it works.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Match Date and Copy Paste - Object Required Error

    Thank you for posting, but there's more to clean...

    Please Login or Register  to view this content.



  5. #5
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Match Date and Copy Paste - Object Required Error

    Thanks Again SNB, but when I run this code nothing seems to happen. I'm looking to make this as clean as possible because I'm eventually going to have to copy and paste about 30 values over 6 workbooks. in the same fashion, by finding the right date reference. Am I implementing the code correctly? I've created a new module in VB and enter the following code. But, upon running , nothing happens? Also, I took out the Resume on Error, because If there was an error I wanted to know. I'm still not confident enough in my coding.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Match Date and Copy Paste - Object Required Error

    Try instead
    Please Login or Register  to view this content.
    Find is certainly more efficient but the code will need to be expanded if the value will possibly be found more than once.
    Last edited by StephenR; 09-05-2011 at 11:47 AM.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Match Date and Copy Paste - Object Required Error

    Try:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-05-2011
    Location
    St. John's, Canada
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: Match Date and Copy Paste - Object Required Error

    Now I'm getting a "Object Variable or With Block Variable Not Set"

    Could it have something to do with the ", ," within the find function?

    the Code below is what I'm trying to Run

    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Match Date and Copy Paste - Object Required Error

    I may have confused you - see my later edited revision above.

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Match Date and Copy Paste - Object Required Error

    You didn't copy correctly: I used xlformulas

    Posting a sample workbook could help.....

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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