+ Reply to Thread
Results 1 to 61 of 61

For a certain condition, copy row's values twice, but change some data in the copy.

  1. #1
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Talking For a certain condition, copy row's values twice, but change some data in the copy.

    Hello!

    Part I: If there is an X in any row in column A in the range A8 to A17, copy the row columns B to P to the next available row in Sheet2. (Sheet2 has a header row.) (This part works.)

    Part II: However, if the row to be copied has Column M = "Dog", then copy the row as-is (this part works), but then also make another copy of that same row, automatically changing "Dog" to "Cat". (This part doesn't work.)

    Part III: Sheet 2 can only contain a max of 10 copied rows. (This part doesn't work if row to be copied is the tenth and contains "Dog".)


    I have a working macro for Part I, but after hours/days of Googling, I can't make the leap to get Part II and III to work.

    Part I:

    Please Login or Register  to view this content.
    This is the last hurdle before this project can hit the streets, so any help appreciated.

    Respectfully,

    Lost

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi John

    Why are you coping the row twice? Do you WANT two labels? I need to understand the logic.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    You got it. For certain conditions, two labels for that same item shouuld print. (In most cases, it will be one tag per item.)

    HTH!

    Lost

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Have some ideas...will get back to you.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi John

    I've moved some things around and replaced your Button on RIR Master with one I created. The Button runs a Macro called "DoStuff" located in Module1...I've also moved your "EditLables" procedure to Module1.

    The "DoStuff" procedure checks to see how many labels will be created based on the Users selection. If it's going to be more than 10 the User will be asked to modify his/her selection. If 10 or less then the "EditLables" procedure is called.

    I commented out the "Protection" lines of code for testing...put them back in when you're ready. Please note...this line of code needs to be modified for the version of the workbook you're running
    Please Login or Register  to view this content.
    or you'll get weird results (happened to me as I created new versions).

    Let me know of issues and what you don't like.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I don't know about you, but we here are getting really excited about what you are doing. We thought this project would get killed because of this row-issue, but you are breathing life back into it. Great stuff!

    I attached a marked-up version. Pink callouts are what I changed or info stuff. Red callouts are where the problems are.

    Thanks for everything!

    Lost
    Attached Files Attached Files

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost
    I'm terribly color blind. I see only one balloon that appears to me to be Red and that balloon contains this

    Only 4 rows X'ed. Two of the rows have H's in Column H. So that should make 4 labels (H,C,N,H), plus 2 more for the H's (changed to A). Six labels total. When I click the button, it says I am making 14 labels.

    The reason for that is you've filled Column A of "Labels"...I was using that column in the code to count the number of lines already existing to determine how many additional lines could be added (to a max of 10).
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    So, I can use another column but it needs to be a column that will always be populated when label data is added. I'm going to assume Column B. Those changes have been incorporated in the attached. Are there any other Red items I've missed?
    Attached Files Attached Files

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Sorry 'bout this...please change this line of code in the "DoStuff" procedure
    Please Login or Register  to view this content.
    Let me know of issues.

  9. #9
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Yes, Column B on the Labels sheet will be good to use for a count. (I want Column A to be Label Position so the user can see where on the Avery sheet that data will populate.)

    I changed the red callout to white.

    Still the same issue, though. X the first four rows on the RIR( Master), hit the button to transfer those rows to the Label sheet, and it says that it is making 14 labels (instead of 6)

    ??

    Lost
    Attached Files Attached Files

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    I'm unable to duplicate this so, I'm wondering if perhaps you're interpreting the message incorrectly. Here's what I'd like you to do. Start with an empty Labels sheet. X all the items on RIR Master (A8:A16). Process the labels. You should get a message that your selection will create 11 labels. Now, deselect A16. 10 labels should be created.

    Clear the Labels sheet. Process A8:A11. Six labels should be created on Labels sheet. DON'T clear Labels sheet. Process A8:A11 once again. You should get a message that your selection will create 12 labels (that is the 6 existing labels plus the six new ones). We don't want 12 so you'll need to modify the selection.

    That's how the code is written...it looks to see how many label items exist in Labels sheet and how many the current selection will create. If the total of the two exceeds 10 you'll get the message.

    Try the process and let me know what you get.

  11. #11
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Still working to follow your steps, but it is erroring-out on me.

    This is Excel 2003, BTW. (That may be relevant.)
    "Error loading DLL" popup.
    VBA: Missing: MS Word 12.0 Object Library.

    <yikes!>

    Lost

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    I'll run the code this evening in Excel 2000...see if there's any issue there. Can't do it now...Grandson is using that platform

    I'll get back to you.

  13. #13
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I think I found the problem. I went back and downloaded the file from post #5 of this thread. I went to VBA and tried to compile it.

    It won't compile because it is looking for that MS Word 12.0 object library.

    We are still old school here with Office 2003 and I think that library is purely Office 2007.

    Sorry about that. Looks like you have to backwards-compatible everything for me (in addition to everything else you are doing.)



    Lost

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Please go to VBA (Alt-->F11)

    In the menu bar at the top click on Tools--> References. You'll probably see Microsoft Word xxx Object Library "Missing". Uncheck it. Then scroll down until you find Microsoft Word xxx Object Library. Check it. Hopefully that'll resolve this issue
    It won't compile because it is looking for that MS Word 12.0 object library.
    I intend to run the code in Excel 2000 later.

    I don't understand...why is this suddenly an issue...you've been able to run the code previously have you not?
    Last edited by jaslake; 09-09-2011 at 05:46 PM.

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Well...I get the same message in Excel 2000
    it says that it is making 14 labels
    Simple fix...this one bothers me
    It won't compile because it is looking for that MS Word 12.0 object library.
    I don't understand...why is this suddenly an issue...you've been able to run the code previously have you not?

  16. #16
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Just wanted to let you know. I went home and downloaded the file from post #9. Both me and my wife's computer have Office 2010. As you already know, the workbook works sweet! I am trying to break it to see if there are any other outlying issues (and I haven't tried it yet with the Word merge file, but I am hopeful about that.)

    And it compiles in Excel 2010.

    So, this whole library-DLL issue is Excel 2007/2010 trying to work with Excel 2003.

    I'm trying to get ahold of Excel 2003 here so I can use 2010 to save-as a 97-2003 file to see if I get the same errors I was seeing at work.

    Thanks for all your help! I am going to spend some time playing with the #9 post file. I'll let you know if I find anything else.

    Needless to say (but I will anyway), you da man!

    Respectfully,

    Lost

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Yeh...I'm workin' on it too. Seems that Excel 2000 WITH Word 2007 works fine (with some modifications to the code). Seems that Excel 2000 WITH Word 2000 chokes.

    What version of Word were you using at the office (I'd assume Word 2003)??

    Not sure what's going on or if I can fix it. I'll continue to look at it over the weekend. If you have any breakthrough...let me know.

  18. #18
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Yes, Office 2003 at work.

    One thing I noticed from XL 2010 at home: Change the dropdowns in column H. The text in the corresponding row in Column M is supposed to change. It's just an IF formula.

    I change H, and M just sits there until I go to M and click the fx (next to the formula bar.)

    It's like Excel is not refreshing itself after I make a change to cell.

    Do you see that on your end, or know what can cause that?

    Lost

  19. #19
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Don't even want to explore this tonight
    Do you see that on your end, or know what can cause that?
    Too late...I'll get back to this tomorrow. Night.

  20. #20
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I appreciate you sticking with me through this.

    I attached the latest version as I know it. I made some formatting and wording edits. I was going to delete the Remmed out code lines, but I didn't know if you needed them for troubleshooting.

    As far as I can see, there is just the M-column-not -updating-with-H-column-changes issue and that's it. (with XL2010).

    With XL2003/Word 2003, we'll see.

    Thanks again, John!

    Respectfully,

    Lost
    Attached Files Attached Files
    Last edited by leaning; 09-09-2011 at 11:53 PM. Reason: edit file

  21. #21
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I figured out the M-column-not-updating thing:

    In XL2010, I had File>options>Formulas>Calculation Options set to Manual vice Automatic.

    <shrug>

    New version attached in case that is something that gets carried with the workbook.

    Looks like there is just the Xl2003 compatibility issue, and this is done!



    Lost
    Attached Files Attached Files

  22. #22
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    The post #18 attachment from the other thread always compiled and I never got the compatibility errors, so I looked at what references were called out:

    VBA, MS EXcel 11.0 OL, OLE Auto, MS Office 11.0 OL, MS FOrm 2.0 OL, MS Word 11.0 OL.

    I looked at Post #21 of this thread and made the references the same. Updated file attached.

    Now it compiles but the the macros for the Edit Labels button are crashing.

    ??

    Lost
    Attached Files Attached Files

  23. #23
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    I'm still working on it. I have a solution that works but is not acceptable from an end user standpoint. I'll post when I feel it's the best I can do. You should know, I'm developing this in Excel 2000/Word 2000 (don't have 2003).

  24. #24
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Well, I'm closer. I'll post the FINAL (for the moment) product tomorrow...still don't like it..file opening takes too long....best I can do (at the moment).

    Please note
    I'm developing this in Excel 2000/Word 2000 (don't have 2003).
    Have no clue if it'll work in Excel 2003/Word 2003 (but it should...I think).

  25. #25
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    The attached has been tested with:
    Excel 2007 --> Word 2007
    Excel 2007 --> Word 2000
    Excel 2000 --> Word 2007
    Excel 2000 --> Word 2000

    I don't have Excel 2003 or Word 2003 to test.

    I've made some changes to accommodate Word 2000 MailMerge. You'll notice that I've moved Worksheet "Labels" to the front of the pack; apparently Word 2000 looks only at the first worksheet.

    The code creates a temporary Workbook "Temp" which houses the labels to be printed. For whatever reason Word 2000 insisted on opening another copy of TagLabelMaker R2a v4.3.xls with this code
    Please Login or Register  to view this content.
    With Word 2000 the user would be prompted with the "Allow Macros" prompt and with a "Read Only" prompt (because the file is already open). So instead the procedure launches Temp.xls which is Macro free and is closed.

    I'm also including two Word files...Label Template 1.doc and Label Template 2.doc. The code checks what version of Word is running and opens the Label Template appropriate to the Word version.

    The "Labels" worksheet has a Timer button that will create the labels and time the procedure. Using Word 2000 it consistently took 65 to 70 seconds. Using Word 2007 takes 3 to 4 seconds. My point is "Let the procedure finish"...it'll tell you how long it took.

    You can remove the button when you're ready (and the code in Module2 if you choose). I hope this works with 2003. Let me know of issues.
    Attached Files Attached Files

  26. #26
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I just wanted to let you know that it looks like it is working fine!

    I am going to work with the file you sent, pretty it up for usability, and try to break it.

    I'll let you know how it goes!

    This never would have come this far without all your work!

    Respectfully,

    Lost

  27. #27
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    At one point, the "copy sheet" buttons on all of my forms stopped working. They were Control Toolbox buttons, but the CommandButton Object>Edit menu (when you right-click the button) vanished from all those buttons. I don't know what is going on there.

    So, I took the cue from you and made mine Forms buttons and put all the code in modules instead of behind the sheets.

    Everything is going OK except for the Copy/Edit Labels button. It now copies to the RIR sheet (copies over itself (!)) rather than copying to the Labels sheet.

    That button has your code behind it so I didn't want to fiddle with it and break it further.

    I appreciate it if you can look into that.

    Thanks!

    Lost
    Attached Files Attached Files

  28. #28
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Far as I recall I've never clicked the button "Copy Sheet" on Sheet "RIR (Master)" nor have I fiddled with the code...had no reason to do so...was not part of the issue I was working on.

    What is it you wish to do with this button? The code runs Macro "Copy Sheets". The code then asks for a sheet name...the user enters a "name" and clicks "ok". The code then makes a copy of the ACTIVE SHEET ("RIR (Master)" and names it what the user has asked it to be named. It's doing exactly as the code has asked it to do.

    What do you want to happen and ...why? What's the reason...helps me to understand your process.

  29. #29
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Sorry if I was confusing.

    Everything is going OK except for the Copy/Edit Labels button. It now copies to the RIR sheet (copies over itself (!)) rather than copying to the Labels sheet.

    That button has your code behind it so I didn't want to fiddle with it and break it further.
    That is where the problem is now. I caused this problem when I changed the buttons from Control to Form.

    When I click the CopyEdit Labels button, it is is copying to the RIR sheet.

    HTH!

    Lost

  30. #30
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    I see a "Copy Sheets" button on Sheet "RIR (Master)". This button is doing as it's asked.

    I don't see a "CopyEdit Labels" button on either sheet in Workbook "TagLabelMaker 5.0.xls", your most recent workbook.

    Don't understand.

  31. #31
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Try this:

    1. Open the attached workbook.
    2. On the RIR (Master) sheet, click the Copy Sheet Button.
    3. Name the Sheet "D".
    4. On the sheet "D", "x" some rows.
    5. On the sheet "D", click the "Open Sheet to Edit Selected Labels" button.
    6. Look at the sheet "D". The "D" sheet form has been wiped out.

    HTH!

    Lost
    Attached Files Attached Files

  32. #32
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Sorry 'bout that...must have had brain freeze last evening...wasen't getting the message at all. The sheet's not being wiped out...the filter on the sheet has not been released. Change this code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  33. #33
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Almost there!

    1) I un-remmed all the protection codes to make sure they are playing. A problem: I protect the sheets, select rows on the RIR (Master), and then click the "Open Sheet to Edit...." button. It jumps to the Label sheet (good). When I go back to the RIR (Master), it is unprotected (bad). So I have the protect code (so that it always protects when it is done) in the wrong place.

    2) On the Label Sheet, click "Make Labels". It gives a Run-time error 1004 about saving workbooks with the same name.


    It was all looking good until I cut-in the protection part of the code.


    Any ideas?

    Lost
    Attached Files Attached Files

  34. #34
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    I'm unable to duplicate this in either Excel 2000 or 2007
    On the Label Sheet, click "Make Labels". It gives a Run-time error 1004 about saving workbooks with the same name
    This appears to be resolved...had Protection code in the wrong place.
    When I go back to the RIR (Master), it is unprotected (bad).
    Let me know of issues.
    Attached Files Attached Files

  35. #35
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    The workbook works great on my hard drive (C:\), but when I copied the files to our server (M:\server\QA) and pushed the "Make Labels" button, I get an Error (Run-time error 1004: PasteSpecial method of Range class failed) in this line:

    Please Login or Register  to view this content.
    I checked and the temp workbook is being created in that server folder.

    I have attached the newest workbook.

    Any ideas?

    Respectfully,

    Lost
    Attached Files Attached Files

  36. #36
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    The Clipboard is getting emptied by this Workbook_Activate code
    Please Login or Register  to view this content.
    Modify the AddNewBook code like so
    Please Login or Register  to view this content.
    That should fix it.

  37. #37
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Thanks for that fix. It worked (of course). Seems it was my disable-copy-paste code that caused the error because it interfered with your code. Sorry about that.

    I am going to see if I can break it this weekend, but I wanted to thank you for all your help and especially with seeing this project to a conclusion!

    Have a good weekend!

    Respectfully,

    Lost

  38. #38
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Glad to help. For your info I put a break point at the
    Please Login or Register  to view this content.
    line of code then looked at the clipboard and it was empty. Then I put a break point at
    Please Login or Register  to view this content.
    and stepped through the code (F8) and saw all this other "stuff" running (code you added since our last conversation). This new code cleared the clipboard. A simple fix...could SEE what was causing the problem.
    By the way...I keep a link to clipboard on my Taskbar so I can view it at any time...you may wish to think about it...look it up.

  39. #39
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I sent your workbook out for user testing. Just one issue that I am trying to see if there is an Excel solution for:

    On the label sheet, if the rows are empty, then don't print those labels. (So, two labels on the Label sheet should print two actual adhesive labels and leave the others blank so as not to waste them.)

    After the merge, the user can go into the Word doc and delete all the unused labels, but I hope there is a better way.

    Another option is to format every MailMerge field in the Label template to "If MailMerge field X ="", then leave blank, otherwise fill in. For such a little label, there are alot of MergeFields to redo, but I am starting on that in case it is the only way to fix this.

    Any ideas?

    Lost
    Attached Files Attached Files
    Last edited by leaning; 09-19-2011 at 04:39 PM. Reason: Add Updated FIle

  40. #40
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Yeah...I've had to deal with that issue in the past. I don't know of an Excel solution. The only solution I've come up with is as you suggest
    Another option is to format every MailMerge field in the Label template to "If MailMerge field X ="", then leave blank, otherwise fill in.
    I realize you have quite a few mergefields to modify but it's a one time effort.

    The other part of this issue is, if you've used 2 labels out of 10, you can turn the Label Sheet 180 degrees and use 1 or more (up to 8) labels on that sheet. I know Avery Labels are expensive...what's the cost compared to your users saying to themselves "I think I have a used sheet here that will accommodate these 6 labels...let's see if I can find it" ...and then, because the used sheets haven't been stored properly, the printer jams. It's happened to me.

    Someone will need to weight the cost...I'd assume that's not you. You're part will be to do the coding so those unused labels don't get printed (again, a one time effort). Your's has been an interesting exercise...let me know how you make out.

  41. #41
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Just had a thought...there could perhaps be a solution from the Word side...don't have any idea...you might want to post this question on the Word Forum. If you do I'd appreciate a link...I'd like to follow it and learn.

  42. #42
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Well...I got the whole blank labels thing to work, added some notes, and prettied up as best I could without adding our company-specific logos, etc. to it. So it was all looking good....until I broke it again.


    With the Labels sheet blank, and 9 or so rows selected to copy over, it's says there's 22 (!)labels to be made.

    You already had the "N-also-makes-an-A" on there, and I copied that to make the additional "H-also-makes-an-A" condition. I probably hosed up the counter.

    Can I get your help once again?

    (Current version attached. It's looking great!)

    Respectfully,

    Lost
    Attached Files Attached Files

  43. #43
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I figured out the problem, but don't know how to fix it syntax-wise.

    You used Col B on the Label sheet for label count.

    When I added my notes Col B, the code thinks those notes are labels.

    Here's the line that needs fixed:

    Please Login or Register  to view this content.
    Can it work with your code to only have it look at B2:B11?

    Respectfully,

    Lost

  44. #44
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I just moved the Notes over a column. It works fine.

    (Newest attached.)

    Thanks!

    Lost
    Attached Files Attached Files
    Last edited by leaning; 09-21-2011 at 09:52 AM. Reason: Fix spelling.

  45. #45
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Glad you figured it out.

  46. #46
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    OK, I finally have a real problem....

    (see attached)

    1. Label sheet has 3 labels to be made.
    2. Go to RIR and x the first 7 rows.
    3. Click Open Sheet...button.
    4. Too many labels (11).
    5. Blank out the bottom X.
    6. Click the button.
    7. Protected sheet error.
    8. Debug or End
    9. Look at the RIR sheet (It is copied over/ wiped out.)

    I don't know why this is coming up this late in the game. Looks like it needs an unprotect line somewhere, but I don't want to put it in the wrong place.

    Any ideas?

    Respectfully,

    Lost
    Attached Files Attached Files

  47. #47
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    In EditLabels I've added the Unprotect line here
    Please Login or Register  to view this content.

    Your counter was also off. In DoStuff I've changed this line of code
    Please Login or Register  to view this content.
    I've also moved a couple other lines of code around but they're inconsequential. Let me know of issues.
    Attached Files Attached Files

  48. #48
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    On the version you just posted:

    1. Press the Open Sheet button.
    2. No Items Selected. OK.
    3. RIR gets copied over/wiped out.

    <grrr>

    Respectfully,

    Lost

  49. #49
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    Sorry...I missed that one. The AutoFilter wasn't getting reset.

    In DoStuff add this line of code
    Please Login or Register  to view this content.
    Let me know of issues.

  50. #50
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I added it in, but did you want me to un-rem or delete the one after End If?


    Please Login or Register  to view this content.
    Lost

  51. #51
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    You can delete it. That's one of the lines I moved.
    I've also moved a couple other lines of code around but they're inconsequential

  52. #52
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    I was a mouse-click from calling this thread Solved, but then I started playing around with the workbook again.


    1. Clear the Label sheet except for Position 10.
    2. Now go to the RIR sheet, x one row, and click the button.
    3. It says that it will make an 11th label, but the Label sheet only has one label on it in Position 10.

    I thought your counter solved that.

    ??

    Lost

  53. #53
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Don't bother with that one. The user can just copy-and-paste that row up. I saw something else, however, and am seeing if I can duplicate it.

    Lost

  54. #54
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    The counter is looking for the last row with data in sheet Labels column B. If position 10 is filled the counter will assume that the Labels sheet is populated by 10 Labels.

    Please explain how this particular scenario gets created (first 9 positions empty but position 10 filled). What's happening in the "Real" world?

  55. #55
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    The Avery label sheet is all used up (labels removed) except for Position 10. The user puts that partial sheet in the printer to use it up, then prints the data from Position 10.

    I adjusted the error note to reflect that:

    Please Login or Register  to view this content.
    Good stuff!

    Lost

  56. #56
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    But how does only position 10 get filled...does the user highlight positions 1 thru 9 and clear contents? Under what circumstances would they do that?

  57. #57
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Smile Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    That's why I changed my help request..

    The user would x a row, push the button to send it to the Label sheet, and then once on the Label sheet, copy and paste that row to Position 10.

    It's all good.

    (Well, we'll see.... )

    Lost

  58. #58
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Talking Re: For a certain condition, copy row's values twice, but change some data in the cop

    Jaslake,

    Just to ensure that you understand the magnitude of what you did here:

    Our company receives in hundreds of parts. We slap a quick tag on it and then dump it on QC to inspect.

    QC types out the RIR and then hand-writes (!) each status tag. They have been doing this for years, hand-writing tags.

    I just got here, knew there had to be a better way, but didn't have the VBA skills to pull it off.

    After posting and reposting here, the project almost got killed because I couldn't solve the final few problems.

    You came along, blew the dust off, and dove in with a purpose...head-first. You stuck with it until it was finished, made a crazy amount of improvements along the way, and made life alot easier for many people here.

    And from the number of hits this thread is getting, there are many others who can benefit from what you have done.

    BTW, not only did you solve this thread, you solved another related one where I started the project to begin with.

    Your help has been extraordinary and I have learned alot from you. I can't wait to get this out to the shop where it will do the most good and we can see if all of your troubleshooting can handle anything our users throw at it.


    A big thank you to you!

    Respectfully,

    Not-so-Lost

  59. #59
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Talking Re: For a certain condition, copy row's values twice, but change some data in the cop

    All,

    Here's the file!

    Yahooo!

    Respectfully,

    Lost
    Attached Files Attached Files

  60. #60
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Not-so-Lost

    You're welcome. Glad I could be of help. Best of luck "Going Live". Let me know of issues.

  61. #61
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: For a certain condition, copy row's values twice, but change some data in the cop

    Hi Lost

    If this resolves your issue please mark your Thread as solved. I'd assume you've missed the window of opportunity to do so yourself so you may need to PM a Moderator to do it for you.

+ 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