+ Reply to Thread
Results 1 to 9 of 9

Copy entire row from master sheet to corresponding sheet based on cell value

  1. #1
    Registered User
    Join Date
    04-19-2021
    Location
    Toronto,Canada
    MS-Off Ver
    2007
    Posts
    4

    Copy entire row from master sheet to corresponding sheet based on cell value

    Hi ,
    Here is what I'm trying to achieve :
    I have all database on Sheet1 . Now based on value in column D (team) I'd like to copy entire row from Sheet1 to corresponding Sheet number. For example if the value is 1 in the column D then entire row gets copied to sheet 1. If the value is 2 then entire row gets copied to sheet 2 and so on. On top of that all copied rows should start from cell "A10" on their corresponding sheets. Please see attached file. The code i have there works fine but with small amount of data. I'm planning on expanding that database and number of worksheets so I'm looking for faster and more efficient code. Please help.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jeffreybrown; 04-21-2021 at 09:49 AM. Reason: Please use code tags!

  2. #2
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    I ran the code and ran within a second, have you tried with larger amount of data? If your sheet1 will grow in the number of rows, you can make this update, this way you dont have to worry about how small or large your dataset is.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-19-2021
    Location
    Toronto,Canada
    MS-Off Ver
    2007
    Posts
    4

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    cubangt,

    Thanks, this helps but I'm still wondering if there is a more efficient way to write this code. I'm planning on adding 30 more sheets so that means i'd would need to add 30 more lines of code with IF and Then statements. In this sample i only have 4 sheets beside master sheet so the code doesn't look bad ( long) but once i add 30 more sheets (teams) then its too long...
    Last edited by jeffreybrown; 04-21-2021 at 09:50 AM. Reason: Removed full quote

  4. #4
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    Ah, so you will want to loop thru all sheets then. Place your code within the loop and in place of the "numbers" you have hard coded, replace that with the I

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-19-2021
    Location
    Toronto,Canada
    MS-Off Ver
    2007
    Posts
    4

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    No, that's not it. Basically I'm looking to replace this long code with too many If and Then statements(below) with short one :

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 04-21-2021 at 09:51 AM.

  6. #6
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    That my bad, mis-read the ask.

    Please Login or Register  to view this content.
    Just tested and worked, so there is 2 things you would need to do for future sheets, if you plan on adding more sheets, you will either need to create the sheets first before running the macro, or i would add another function, that checks if the sheet exists, if not, then create it before doing the copy.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,513

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    It assumes that the sheets in question exist.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-19-2021
    Location
    Toronto,Canada
    MS-Off Ver
    2007
    Posts
    4

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    Quote Originally Posted by cubangt View Post
    That my bad, mis-read the ask.
    That's the one ! Thank you very much.
    Last edited by jeffreybrown; 04-21-2021 at 09:52 AM. Reason: Removed full quote!

  9. #9
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Copy entire row from master sheet to corresponding sheet based on cell value

    Hi WernerZiegler123,

    When posting code, please use code tags. Also, please do not fully quote another thread. It just causes clutter.
    HTH
    Regards, Jeff

+ 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. Copy entire row from one sheet to another and back based on one cell value
    By ElrikaHF in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-26-2016, 06:10 PM
  2. Replies: 1
    Last Post: 09-15-2014, 01:03 PM
  3. Copy Entire Row To Another Sheet Based On Cell Value
    By jcontes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2014, 03:22 PM
  4. Copy entire row from Master sheet based on two criteria
    By melispol44 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2013, 08:07 PM
  5. Copy entire row to another sheet based on cell color
    By Marco-Kun in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-18-2013, 09:13 AM
  6. [SOLVED] Copy entire row to appropriate sheet based on value of cell in row E
    By engineerjason in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 11-12-2012, 07:48 PM
  7. Copy/Cut entire row to another sheet based on cell value
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-02-2010, 04:23 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