+ Reply to Thread
Results 1 to 8 of 8

Thread: Lookup date and Paste transposed data?

  1. #1
    Registered User
    Join Date
    02-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Lookup date and Paste transposed data?


    Cells C11:C45 have pre numeric data.
    Cells D11:D45 have post numeric data.
    C5 has a date in the following format 2/8/2012 13:30.
    Trying to make my macro recognize the date and transpose the pre and post data in another tab in a row with said date in this format 2/8/2012.
    Of course the data changes every day so I need my macro to throw the new data in the new row (2/9/12 for example).
    Any help is appreciated.
    maybe a box of girl scout cookies?
    Last edited by ImagineParidise; 02-10-2012 at 02:09 PM. Reason: admin rule violation

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    359

    Re: Lookup date and Paste transposed data?

    Can you upload a sample workbook with no sensitive data showing how the data currently is presented and how you want it to appear - So in a sample sheet give a few examples of how you want the data to be appear after the macro has run. It makes it much easier to supply you an accurate answer if we can see how your workbook is constructed and if we can see an example of how the workbook is to appear after the macro has processed the data. Select Go Advanced, Manage Attachments and select the dummy workbook to upload. Make sure no sensitive/private data is in the workbook you upload. Do not upload screen dumps as no one wants to reconstruct a workbook based on an image.
    You will have a much better chance of getting an answer if you could supply a sample workbook.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated

  3. #3
    Registered User
    Join Date
    02-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Lookup date and Paste transposed data?

    Ok, here we go...I wanted to get my before and after data copied and transposed to a specific date which is in cell C5... The attached workbook is an "After" of what it should look like.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Lookup date and Paste transposed data?

    I'm thinking Range.Find but don't know where to start past the excel help associated with this VBA command...

  5. #5
    Registered User
    Join Date
    02-08-2012
    Location
    South Suffolk
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Lookup date and Paste transposed data?

    Does this do it?
    Option Explicit
    
    Sub Do_Data()
    Dim dDate As Date
    Dim rBefore As Range, rAfter As Range
    Dim rSourceBefore As Range, rSourceAfter As Range
    
    dDate = Int(Worksheets("Data").Range("C5").Value)
    
    Set rBefore = Worksheets("Date Before").Range("A:A").Find(dDate)(1, 2)
    Set rAfter = Worksheets("Date After").Range("A:A").Find(dDate)(1, 2)
    
    Set rSourceBefore = Worksheets("Data").Range("C11:C45")
    Set rSourceAfter = Worksheets("Data").Range("D11:D45")
    
    rSourceBefore.Copy
    rBefore.PasteSpecial xlPasteAll, xlPasteSpecialOperationNone, , True
    
    rSourceAfter.Copy
    rAfter.PasteSpecial xlPasteAll, xlPasteSpecialOperationNone, , True
    
    End Sub

  6. #6
    Registered User
    Join Date
    02-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Cool Re: Lookup date and Paste transposed data?

    Looks good and works well. Thank you very much! you are now my new best friend ;o

  7. #7
    Registered User
    Join Date
    02-10-2012
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Lookup date and Paste transposed data?

    actually, i get a "Run-time error '13': Type mismatch" error with the dDate line when trying to copy it over to another worksheet... any ideas?

  8. #8
    Registered User
    Join Date
    02-08-2012
    Location
    South Suffolk
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Lookup date and Paste transposed data?

    Have you checked the contents of the date cell (C5)? It could be text and it may be necessary to force to a date.

+ 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.2.0