+ Reply to Thread
Results 1 to 26 of 26

copy and paste row if column c contains certain info

  1. #1
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    copy and paste row if column c contains certain info

    Hi,
    I am working on a project but seem to be going nowhere with it, andbody that could help please let me know.

    I have a worksheet. and i would like to copy and paste all rows in that worksheet where Column C contains data between CA0010000 to CA0019999. Column C also contains numbers that look like that eg. CA00500322, stuff like that, this will go on seperate worksheets.
    So i would like to have excel automatically transfer a row that meets that criteria (Column c contains CA0010000 to CA0019999) to a seperate worksheet in the same workbook.

    i was hoping this will be like a real time process. transfers as we type it in or as we copy and paste data in the "masterlog". column c in the masterlog is where the source would be and another worksheet named CA0010000 would be where i would like the whole row to be transfered to.

    any help will be highly appreciated

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    Please attach a sample workbook so we can help you better.

  3. #3
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    THANKS FOR YOUR HELP
    i am trying to auto transfer all range between ca0010000-ca0019999 to "ALAMEDA" which is sheet 2.
    and as you will see in the example, all CA0380000 or anywhere between CA0380000 to CA0389999 shoould transfer to the SAN FRANCISCO tab.
    I am hoping that the whole row will transfer as it is typed in or as get copied and pasted from somewhere to the "MASTER" sheet.

    thanks again
    Attached Files Attached Files

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    Your sample file doesnt show any headings. Will the file that you will be using daily have headers? Need to know for the code. When the transfer happens, should the data continue to remain in the Master tab? So in other words, is it a copy paste or a cut paste?
    Last edited by arlu1201; 10-14-2011 at 02:25 AM.

  5. #5
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    first of all Thanks for your help and thanks for your time.
    No its actually a monthly log.
    the problem i face is people working under me has problems cutting and pasting to respective tabs. so the master log stays for a month everything they copy into it is actually copied from an excel that does not have any code, formulas or anyhting. its a simple copy and paste. but i want to make it easy and have them cut and paste it to a master log and it should transfer to respective tabs. i would like to keep the master log, so its actually copy and paste as they copy from x sheet to my master.
    once again thanks
    I just want to get my Excel working because i am working on it for a while now.
    thanks
    Last edited by Paul; 11-05-2011 at 12:52 PM. Reason: Removed e-mail address

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    Another question. Once the data is copied today for example, if the user wants to copy the data again tomorrow, wont it result in duplicates? Is there a way to identify which records have already been copied v/s those that havent?

  7. #7
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    everything from the master log transfers as they are pasted, and also stays on the master log. the next day more is pasted right on the master(next available line).
    the master keeps getting entries for a month.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    I understand this correctly. However, my question is....if today the user copies from the master to the "Alameda" tab and again tomorrow there is more data to be added, should the new data be appended to the next available line in the ALAMEDA tab or should everything be copied again?
    Is there a way to identify which records have already been copied from the master v/s those that havent?

  9. #9
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    all the users will only be able to access the master log only.
    all other tabs like Alameda will be locked. what they paste in master log should automatically go to the corresponding tabs. the next or whenever something else is pasted on master log Excel should detect which tab it should go to and then paste it on the next available line in that tab (worksheet)
    did i answer your question?

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    Yes .. but is it ok if we have a tick mark or something in the master tab to identify that the row has been copied?

  11. #11
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    i think i understand you, yes you can have a tick mark on each row somewhere.
    or color code the rows that has been copied. but i wanted Excel to automatically detect the once that have been copied already. the tick mark you talking about is that something i have to go and manually put it in each row.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    No if we go with the tick mark, excel will put it for you once the copy is done and it will remain in the master tab. The next day, when the macro attempts to copy the data over, it will check for the tick mark and skip that row.

  13. #13
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    that should work them
    thanks again

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    Will try and have something ready for you by today.

  15. #15
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    thanks for all the help

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    First of all, in column D of your Master tab, i have formatted that entire column to Webdings. The code will insert a tick mark in this column every time a row is copied. Try this code and let me know.

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    i copied and pasted the code under the View Code in the master tab and hit run but its giving me an error.
    is that what i was supposed to do.
    it was selecting the first row and that was it.

  18. #18
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    ca we put a code like if column "c" is >= CA0010000 and <= CA0019999
    then paste those row to Alameda Tab

    then i will have to put those tabs for all the rest of the tabs, example if column "c" is >= CA0380000 and <= CA0389999
    then paste those row to San Francisco Tab.

    reason I as is there is 52 tabs after the master which are different names just like San Francisco and Alameda.

  19. #19
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    You should put the code in the module. To do that, open the excel file, press Alt+F11, right click on Microsoft Excel Objects and insert ->Module. Then copy the code over.

    You had specified 2 conditions, namely, >= CA0010000 and <= CA0019999 (which i have done the same way) and > CA0019999. If you do have more conditions, please provide all of them and i can get them coded for you. I have only specified 2 right now as you had provided me.

  20. #20
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    sorry about the confusion. that was actually just a sample. there are 52 tabs other than the master log. basically 52 different places example, Alameda, San Francisco, and more. I assumed I will be able to take one code put it in multiple times in the same module and i will just change the CA codes and Tab name to be transfered in. since there were 52 places or different tabs that is why I did not give all to you.

  21. #21
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    Ok i guess we can simplify this easily. What we can do is use some blank columns in your master tab where in you can put the various conditions and the sheet where it has to go to. The code can loop through all these conditions and perform the necessary actions.

    Will this work for you?

  22. #22
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    yes, that sounds good. the only column that matters is, the master tab is column C. Conditions will change only in column C.
    Like CA0010000-CA0019999, CA0020000-CA0029999, and so on. This is just an example.
    If you show me a sample code that will transfer say, CA0010000-CA0019999 over to Tab named Alameda, i will try to modify that code as needed and try to do it where the rest goes to respective tabs when conditions change in Column C. (might need some help but I can try)

  23. #23
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    In the Master tab, i have put in some values in columns AA to AC. You can fill these up with your various conditions and see if it works. I have attached the worksheet here.

    Try this code and let me know if you face any issues.

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

  24. #24
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    Did the code above work for you?

  25. #25
    Registered User
    Join Date
    10-11-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: copy and paste row if column c contains certain info

    No it didint. But I dont think I am putting the code at the right place. I right click on master tab then click "view code". Then paste it. Then I hit run. But it doesn't work. I wanted it to work as new entries are made where I don't have to run a macro every time.

  26. #26
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: copy and paste row if column c contains certain info

    No, what i have worked out for you is to run a macro separately. For this you need to put the code in a blank module and not in the view code section of any sheet.

    To be able to
    I wanted it to work as new entries are made where I don't have to run a macro every time.
    , we will have to change the way it is currently working as we will need to check for items that have already been copied and then copy the uncopied items.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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