+ Reply to Thread
Results 1 to 17 of 17

Macro to copy data to sheet "All Vehicles" based on headings on this sheet

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    I have headings in row1 on sheet "All Vehicles"

    I have tried to write code to copy the data from sheets "New Vehicles" and "Used Vehicles" where the column headings match

    for Eg Where "Stock Number" is in A1 on sheet "All Vehicles" then copy this data from Used Vehicles" and "New Vehicles" from the column containing this header in row1 and paste in row2 onwards on sheet "All vehicles" The same goes for the balance of the headings

    When running the code only the data from "used vehicles" is copied and pasted on sheet "All Vehicles"


    Kindly test and amend

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    265

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Dear Howardc1001 please try this code with my understanding

    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,652

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,508

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Please Login or Register  to view this content.
    [/COLOR]

    You overwrite "New" with "Used" as you start with row 2 rather then then "Lastrow" associated with "New" - the logic for this is wrong.

    Check your "LastRowAll" logic in BOTH New/Used code blocks AND learn how to step through code to find errors.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Hi Jindon

    Thanks for the help. Your code works 100%

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,652

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    That's good and thanks for the rep.

  7. #7
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Dear sudbhavani

    The code is extracting the data in the incorrect columns for some of the headers

    See final result on sheet "All Vehicles" of what it should look like as well as result on sheet "All vehicles" when running your code

  8. #8
    Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    265

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Quote Originally Posted by Howardc1001 View Post
    Dear sudbhavani

    The code is extracting the data in the incorrect columns for some of the headers

    See final result on sheet "All Vehicles" of what it should look like as well as result on sheet "All vehicles" when running your code
    Dear please check now

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,436

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Howard...Just out of curiosity...
    Are your New Vehicle & Used Vehicle headers always in the same position...
    Does Used Vehicle tab never have a Year header...
    Last edited by Sintek; 05-10-2024 at 05:36 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  10. #10
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Another way
    Please Login or Register  to view this content.
    Last edited by daboho; 05-11-2024 at 04:44 PM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

  11. #11
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Sintek -The "Used Vehicle" Tab does has a Registration date

    The Header Names will always be in the same position for New Vehicle & Used Vehicle

  12. #12
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Perfect now sudbhavani

  13. #13
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Thaanks for your code, but no data copied

  14. #14
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,436

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    The "Used Vehicle" Tab does has a Registration date
    Nope...YEAR Header

    Just for the fun of it...

    Please Login or Register  to view this content.
    Last edited by Sintek; 05-10-2024 at 06:05 AM.

  15. #15
    Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    265

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Quote Originally Posted by Howardc1001 View Post
    Perfect now sudbhavani
    thanks for the rep.howaed

  16. #16
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Thanks Very much Sintek

    Code works 100%

  17. #17
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,436

    Re: Macro to copy data to sheet "All Vehicles" based on headings on this sheet

    Thanks for feedback Howard...And rep +

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to Copy Data where Sheet Names are the Same from sheet "Bad Debts" onwards
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2023, 10:52 AM
  2. Replies: 0
    Last Post: 05-04-2023, 11:09 AM
  3. [SOLVED] Macro to Copy Headings from Sheet "885201" to specified sheets
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2023, 02:54 AM
  4. many actions in one macro: copy sheet "G" and paste "g_koond" no empty rows and add ID
    By reinsermat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-05-2020, 04:28 AM
  5. [SOLVED] Copy Data from "Source" Sheet to "Target" Sheet (Code need help thanks)
    By mankit87 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-17-2019, 11:45 PM
  6. Replies: 2
    Last Post: 06-28-2016, 03:57 PM
  7. Looping thru rows and copy cell values from "Inputs" sheet to "Output" sheet
    By hariexcel1987 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2015, 11:32 PM

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