+ Reply to Thread
Results 1 to 10 of 10

Copy Cells from on sheet to another based on value in cell

  1. #1
    Registered User
    Join Date
    01-26-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    9

    Copy Cells from on sheet to another based on value in cell

    I saw in another post that someone was pasting values from one sheet to another. In my macro I want it to do this but only on certain cells and only if the value in cell E is X.

    So it would be If E="X" then copy cell values from columns(A,B,C,D,F,G) on active row into worksheet. Also if (sheet1.D.row number) = (sheet2.column D) then replace if does not exist add to end.

    Any directions about how its best way to achieve something like this would be great.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copy Cells from on sheet to another based on value in cell

    Hello carlysyme,

    Maybe this loses something in the translation...
    Also if (sheet1.D.row number) = (sheet2.column D) then replace if does not exist add to end.
    But "D" is a column. Can you provide an example of what you want to do?

  3. #3
    Registered User
    Join Date
    01-26-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Copy Cells from on sheet to another based on value in cell

    This what i want it to do:

    Please Login or Register  to view this content.
    sorry for thr rough pseudo code but i am guessing someone is going to tell to do this completly different to what I come up with just want to see you ideas about how should do this.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copy Cells from on sheet to another based on value in cell

    Hello carlysyme,

    Perfectly clear now, thanks. I need a few minutes to code that up for you.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    08-20-2004
    Posts
    7

    Re: Copy Cells from on sheet to another based on value in cell

    I'll be interested to seeing with what you come up with Leith. I'm looking for a similar solution.

    I have a spreadsheet that in Column B, users will type a code (R1, R2, R3, CC, etc). I was wanting the user to be able to click within the row, click a button and have that row copied to the corresponding sheet. In other words, if in cell B3, the user enters R3, the row should be copied to sheet called R3 in the first available row. The reason why I can't do this with formulas is that this worksheet is shared and and multiple people will be working in the sheets (R1, R2, etc) and if the data gets cleared out on the main sheet, then we don't want the data cleared from the other sheets.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copy Cells from on sheet to another based on value in cell

    Hello carlysyme,

    I think I confused myself. Correct me if i wrong about this.

    1. If there is an "X" in column "E" of Sheet1 copy the data from columns "A,B,C,D,F,G" of the same row.

    2. If the value in "Sheet1" column "D" of that row equals any value in column "D" of "Sheet2" then paste the data at the end of the range.

    3. If the value in "Sheet1" column "D" doesn't equal any value in column "D" of "Sheet2" then replace the data of that row.

    Is that correct?

  7. #7
    Registered User
    Join Date
    01-26-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Copy Cells from on sheet to another based on value in cell

    1. If there is an "X" in column "E" of Sheet1 copy the data from columns "A,B,C,D,F,G" of the same row.
    Thats correct.

    2. If the value in "Sheet1" column "D" of that row equals any value in column "D" of "Sheet2" then paste the data at the end of the range.
    if it equals then it should replace

    3. If the value in "Sheet1" column "D" doesn't equal any value in column "D" of "Sheet2" then replace the data of that row.
    if it does not equal then it is a new row and should amended to existing data

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Copy Cells from on sheet to another based on value in cell

    Hello carlysyme,

    This macro will replace the data on Sheet2 or append it to the sheet. Column "E" of Sheet1 is not copied over to Sheet2. Both sheets are assumed to start in row 1.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-26-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Copy Cells from on sheet to another based on value in cell

    Please Login or Register  to view this content.
    This section seems to insert somekind of object and application error.

  10. #10
    Registered User
    Join Date
    07-21-2011
    Location
    Egypt
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Copy Cells from on sheet to another based on value in cell

    Hey Mr.
    i can not working well with the VB Codes but i'm asking for your help in my project.
    here's what i'm searching for:
    i have data in my worksheet that retrieved from another workbooks
    now and for examples: if i need to copy all the data from A1:T1 at Sheet1 and past it on A1:T1 at sheet2 based on a certain value in sheet1"Only when Z1=100"
    Then i need to repeat this case again as following: copy from A1:T1 sheet1 and past it in A2:T2 sheet2 Only when Z1=200
    and so on ..........

    in another words:
    if z1 at sheet1 =100 >--So--> copy A1:T1 at Sheet1 and past it on A1:T1 at sheet2
    if z1 at sheet1=200 , copy A1:T1 at Sheet1 and past it on A2:T2 at sheet2
    if z1 at sheet1=300 , copy A1:T1 at Sheet1 and past it on A3:T3 at sheet2
    if z1 at sheet1=400 , copy A1:T1 at Sheet1 and past it on A4:T4 at sheet2
    and so on...
    hope to find your reply ASAP as it's really important and critical to me .
    thanks in advance

+ 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