+ Reply to Thread
Results 1 to 5 of 5

Macro to copy certain columns from one sheet to another but no further than column E

  1. #1
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Macro to copy certain columns from one sheet to another but no further than column E

    Hi. I need a macro to copy certain columns from one sheet to another. I already have code that sort of works that I have taken from elsewhere but I need little bit help to correctly finish it off. I have sheets called "Hyperlink" (the source sheet) and ME22 (the destination sheet).

    The code that I have so far does the following:
    It takes info from column 4 from source sheet and places in column 1 on destination sheet
    It takes info from column 5 from source sheet and places in column 2 on destination sheet
    It places letter "X" in column 3 on destination sheet
    It takes info from column 14 from source sheet and places in column 4 on destination sheet
    It places the following to col 5 on destination sheet - concatenation of text "Supp Recoll" + column 21 and column 14 from source sheet

    Now the code that I so far have is the following:
    Please Login or Register  to view this content.
    1) Now the problem with this current code is that it carries on copying information from source sheet to destination sheet as far as it column 24. I want it to stop at column 5 (column E) as the last column being filled in. Rest of the columns should stay clear. How can I adjust my code to make this happen?
    2) Line : With Sheets("ME22"): maxval = Application.Max(.Range(.[a2], .Cells(Rows.Count, "a").End(xlUp))). How could I change this line as the "maxval" was defined in the original code that I used to learn and to get this far. This feature is not required in my macro but I have no idea how to remove it without rendering the rest of the code useless.

    All ideas are ideas are welcome. I have attached a test spreadsheet.
    Attached Files Attached Files
    Last edited by rain4u; 05-28-2011 at 03:07 PM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro to copy certain columns from one sheet to another but no further than colum

    hi, Rain,
    1) and 2) all together

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: Macro to copy certain columns from one sheet to another but no further than colum

    Hi watersev
    Thank you. It works exactly as required. Original code was taken from one of your earlier codes that you helped me with. I'm starting to understand bit more of these codes which is great. There is still lot to learn.

    Thanks again
    Rain

  4. #4
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: Macro to copy certain columns from one sheet to another but no further than colum

    Hi watersev
    I would like to have values in columns 4 and 5 in certain date format as this information is copied and pasted to a system that does only accept format dd.mm.yyyy
    So within this line
    Please Login or Register  to view this content.

    How do I have to change sections a(i, 4) = a(i, 14): and & a(i, 14) so the values would be in format dd.mm.yyyy

    Currently if I would use a separate macro like find "/" and replace with "."
    Please Login or Register  to view this content.
    This messes up the dates. i.e if its 31/01/2011 then after macro it would be 01.31.2011
    I would like to have this correct already when transferring data from one sheet to another.
    Can you please advise if this can be done?


    Cheers
    Rain

  5. #5
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: Macro to copy certain columns from one sheet to another but no further than colum

    I figured this out myself I'm super happy for learning this. If anyone else is interested how to achieve this, please see below:
    Please Login or Register  to view this content.
    Thank you watersev for your help. The code is now perfect

+ 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