+ Reply to Thread
Results 1 to 14 of 14

If date and driver match move cells to end of row

  1. #1
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    If date and driver match move cells to end of row

    Hi All

    I am looking for help this problem. I have data that requires sorting. If the date and the driver matches then move the vehicle and KPL to the same row as per the attached example.

    Hope someone can help?

    many thanks in advance

    Jim
    Attached Files Attached Files
    Last edited by jimbob121; 10-23-2010 at 11:56 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: If date and driver match move cells to end of row

    AS A PRECAUTION SAVE THE FILE SOMEWHERE ALSO SO THAT THE FILE CAN BE RETRIEVED IF THERE IS A MESS UP.

    for easy debugging I have given four macros. all the macros should be parked in a standard module.

    BUT YOU NEED RUN ONLY "A_test".
    the prefix A is given so that this macro will be the first in the list.
    The results are in sheet2(repeat sheet2)

    I have left some cosmetic changes like filling up all the column headings in sheet2 as the number of columns is indeterminate depending upon your original data.

    I would like to have your comments.


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

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    Many Many thanks

    What as superb piece of code!!

    The only problems I have is that I have a 100 plus rows to sort. If I add another row I get debug error as follows

    Please Login or Register  to view this content.
    Many thanks again

    Jim

    Spoke to soon. It works ok if I copy all examples down again, the error states application defined or object defined error.

    It must be the values of the actual data I am copying in. An example of the drivers name is Keith Smith and an example of the Vehicle is HX55 LMO.
    Last edited by jimbob121; 10-18-2010 at 11:38 AM. Reason: a new coder

  4. #4
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    Hi VenKat1926

    The issue I have seems to be related to the drivers name only. I can change vehicles colum ok. I can not have more than 3 drivers. Is there anyway to change this as I have may have 50 diferrent drivers spread across 100 plus rows.

    Many thanks again

    Jim
    Last edited by jimbob121; 10-18-2010 at 03:07 PM.

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

    Re: If date and driver match move cells to end of row

    or
    Please Login or Register  to view this content.



  6. #6
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    snb

    Many thanks for your code. Sorry about the delay in responding. Your solution works well be seems to miss the last line data. Many thanks in advance if you look at it.

    thanks

    jim

  7. #7
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    Snb

    Thanks again for the code. Could you help me a bit further and change the code to out to sheet2 and as mentioned before the code misses the last line of data. I can get round this by adding another line and it works ok

    Regards

    jim

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

    Re: If date and driver match move cells to end of row

    Change this:

    With Cells(20, 1).Resize(UBound(Split(c02, vbCr))+1)

  9. #9
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    @snb

    Thanks you very very much!!

    Works great!

  10. #10
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    Hi snb

    Sorry but I have a date issue. When the data is sorted, it reverses the date from UK to US style. i.e dd/mm/yyyy to mm/dd/yyyy this only happens when the date is low enough to fit US style which is why I missed it.

    Many thanks for your time again

  11. #11
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    @snb

    Any ideas on date issue?

    Many thanks for your time.

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

    Re: If date and driver match move cells to end of row

    ()
    ------
    For jj = 1 To UBound(sq, 2)
    c01 = c01 & "|" & iif(jj=1,format(sq(j,jj),"m-d-yyyy"),sq(j, jj))
    Next
    -----

  13. #13
    Registered User
    Join Date
    08-24-2010
    Location
    glasgow
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: If date and driver match move cells to end of row

    thanks you once again.

    Works superb!!

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

    Re: If date and driver match move cells to end of row

    no further relevance
    Last edited by snb; 10-23-2010 at 12:40 PM.

+ 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