+ Reply to Thread
Results 1 to 22 of 22

Need to write VB macro in excel to copy the set of data with the latest date

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Question Need to write VB macro in excel to copy the set of data with the latest date

    Hi All,

    I have the data in excel 2007 for devices (different devices), which are updated in different date.
    Need to write Vb macro so that rows of data will be copied to different sheet for devices which are updated in latest date

    Excel sheet is attached for the reference.
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Maybe you can show us how you want your output to appear.

    You want only the latest date to show up for each device name? Do you want all the columns to show up in the output?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    I need all the column data to show up with latest date of device.
    I have just changed the excel where B column is device and E Column is updated date.
    Here I have to fetch all the data(all the columns) of the devices which is updated in the latest date
    Excel is attached for the reference.
    Actually I have 80,000 data so please let me know which method(Vb macro or Formula) will be faster.
    Attached Files Attached Files
    Last edited by taps135; 05-02-2013 at 01:52 AM.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Taps,
    This is a duplicate post, but I am diverted in to this thread
    Okay, I have now much faster code. The outcome is in new sheet, but can be changed to the same sheet. Try it.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Thanks a lot AB33 . This code is solved my problem. I have little bit changed in my excel .
    I have to get the data for devices on the basis of latest date
    B column is for devices
    E column for date
    Excel is attached for the reference
    As I don't have much idea on the coding part can you please help me
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Tabs,
    Okay, but for some unknown reason, I can not download the attached. Could you please upload it again.

  7. #7
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Okay.Attaching the file once again
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Taps,
    The same problem,
    Could you please attach like post #3. I can open post 3. You can remove post 3 and replace it with a new one.

  9. #9
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Again attaching the file
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    No, I am going to contact, Arlu the admin, if the issue is at my end.

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    It says the file is corrupted. Taps, ensure that you do a proper save-as on the file. Do not just change the file extension.

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Arlu,
    Thank you for your help!
    I can open post #3, not any attachment afterwards.

  13. #13
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Once again attaching file by the name SampleData.
    Still if you will not able to open the file then just change the two column in your code
    Make B column in place of A(Device No)
    Make E column in place of C(Date)

    Hopefully this time excel will be opened
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Yes, I can now open it.
    Attached Files Attached Files
    Last edited by AB33; 05-06-2013 at 09:49 AM.

  15. #15
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Thanks a lot again.You have saved my time.
    Need one more help I want the latest records will be copied to another sheet instead of adding a new sheet or the data will be copied to another sheet from the added sheet(latest data).Because I have to implement some formulas on the another sheet.Can you help me on this

  16. #16
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    The code creates a new sheet and produce the result in to this new sheet. What do you mean copy in to another sheet? What is the name of the sheet you want to copy in to?

    Change this part of the code

    With Sheets.Add

    In to

    With Sheets("Sheet1")

    Where sheet1 is the name of the sheet where you want to copy it.
    If it is sheet3, change it sheet3 and so on.

  17. #17
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    I got it.My purpose is solved.Thanks a lot again for all your help

  18. #18
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Hi AB33,

    I am facing some problem in the macro which is written in Sampledata.xlsm‎ ( You have replied on post #14)

    If you will see the macro result (after run the macro),you will find the device number 0572DC0183 which is not picking the correct data of C and D column.
    device number 0572DC0183 latest updated date is 1/11/2012 10:58:22 AM which is picking correctly .But the data for C and D column for the date 1/11/2012 is taking blank however there is different data is available for it

  19. #19
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    See post 14 again

  20. #20
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Thanks a lot for the the help.One more help I need in this macro,Can you please sort the B column in Ascending order first then on the basis of Device name (B column) sort the the E column (date) in ascending order.

    Note-In the starting of macro sort the column

  21. #21
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Taps,
    You now need to close this thread. I believe your original request has been resolved. This sorting is another request which is not related to the first thread. You need to start a new post.

  22. #22
    Registered User
    Join Date
    04-24-2013
    Location
    delhi
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Need to write VB macro in excel to copy the set of data with the latest date

    Yes will do in different thread

+ 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