PrintLoop starting at the wrong row, printing two copies

cruspy

New Member
Joined
Oct 5, 2015
Messages
5
Below is my code. I'm using this to get values from one sheet and <gs id="32d3c0d2-63fb-4a32-a1b5-a92cb9d18892" ginger_software_uiphraseguid="eacdfcb3-5f98-4da1-9367-ba2ef279b2bd" class="GINGER_SOFTWARE_mark">autofilling</gs> it into another sheet. What I want is to have it start from the top of the first sheet and after printing the values in that row, to continue all the way to the end of the sheet. However, instead of starting at A6 and using the values there, the macro starts at A61 and prints two copies for some reason. Any help correcting my code would be greatly appreciated!

Code:
Sub <gs id="d8b9e8ee-e223-4fb2-9187-770a834813ee" ginger_software_uiphraseguid="3c0ca7c2-03af-479a-b771-3eddb5becfc3" class="GINGER_SOFTWARE_mark"><gs id="3e8c4b93-f8eb-43bd-be13-475333e3afa4" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">PrintLoop</gs></gs><gs id="797a1a89-74f2-484d-a948-db0c194a6174" ginger_software_uiphraseguid="3c0ca7c2-03af-479a-b771-3eddb5becfc3" class="GINGER_SOFTWARE_mark"><gs id="e4313665-2035-4925-b37d-26cbfafdea0e" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs><gs id="60bf3d46-c9c3-421a-8435-3dd5b24d9582" ginger_software_uiphraseguid="3c0ca7c2-03af-479a-b771-3eddb5becfc3" class="GINGER_SOFTWARE_mark"><gs id="5b894907-9109-4ea2-953c-e0aa17e2b308" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">)</gs></gs>Dim LR As Long, <gs id="81b84e51-6df2-4906-89f2-ce38f0bd6a28" ginger_software_uiphraseguid="3c0ca7c2-03af-479a-b771-3eddb5becfc3" class="GINGER_SOFTWARE_mark"><gs id="87d517be-0fe0-4418-8c06-eb0bd3161dfe" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">i</gs></gs> As Long
Application<gs id="b3252804-cd1e-47fb-abfb-ca20d0a2de4f" ginger_software_uiphraseguid="486ca1c6-4355-446b-b165-c00bff7a0691" class="GINGER_SOFTWARE_mark"><gs id="456e992f-466e-476c-968b-9f42f9e5ad89" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>ScreenUpdating = False
With Sheets<gs id="15f70439-fc20-419d-959d-4177cad87153" ginger_software_uiphraseguid="eb039b14-eba7-4306-8906-8b3c998446b7" class="GINGER_SOFTWARE_mark"><gs id="2e84b3fd-7159-40d6-894a-d42b0c53dd85" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs>"Test")
    LR =<gs id="e4cf1c24-65c5-4d96-b27e-101586b3ac01" ginger_software_uiphraseguid="6dc46e33-e2bd-435f-848e-e75c018d2c69" class="GINGER_SOFTWARE_mark"><gs id="7e828011-ddd6-4f23-bea0-fbe52e3ae578" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark"> .</gs></gs>Range<gs id="eb99ad2b-9b7a-465e-bc54-bc0a8e515bf4" ginger_software_uiphraseguid="6dc46e33-e2bd-435f-848e-e75c018d2c69" class="GINGER_SOFTWARE_mark"><gs id="c3515828-d210-4de0-8aa9-806bfd1a0d22" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs>"A" & Rows<gs id="2603745b-54a3-4f67-ad48-5e6a75e36098" ginger_software_uiphraseguid="6dc46e33-e2bd-435f-848e-e75c018d2c69" class="GINGER_SOFTWARE_mark"><gs id="2ccdd2e8-a302-4a3c-bd96-79b268ee8f62" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>Count)<gs id="b2367f92-8ee3-4ab9-9ca7-618afa61faa9" ginger_software_uiphraseguid="6dc46e33-e2bd-435f-848e-e75c018d2c69" class="GINGER_SOFTWARE_mark"><gs id="48e1ccd0-5f7c-4052-ad26-c0dfdc4a3b0c" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>End<gs id="b962d78a-3a98-4f1b-a755-5b06352662b5" ginger_software_uiphraseguid="6dc46e33-e2bd-435f-848e-e75c018d2c69" class="GINGER_SOFTWARE_mark"><gs id="be3cd108-e07b-442b-9fd0-751c8ff6f415" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs><gs id="bec45bb5-3ae2-4453-992c-32712f467761" ginger_software_uiphraseguid="6dc46e33-e2bd-435f-848e-e75c018d2c69" class="GINGER_SOFTWARE_mark"><gs id="c2e67845-3ee4-4a08-a08a-ca47b7293d25" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">xlUp</gs></gs>)<gs id="f1a53473-7831-446e-988b-daf62435857d" ginger_software_uiphraseguid="6dc46e33-e2bd-435f-848e-e75c018d2c69" class="GINGER_SOFTWARE_mark"><gs id="244d55e3-0a5b-45c5-ab6a-0f515eb8fc5b" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>Row
    For <gs id="cb6eb85b-c78e-4c9b-a507-dd2fe0e22243" ginger_software_uiphraseguid="20630e3d-b10a-4db0-9ac9-faca2aa61b7a" class="GINGER_SOFTWARE_mark"><gs id="b7274237-c499-483e-9b5f-1fd1291bfedf" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">i</gs></gs> = 1 <gs id="bfc2e65a-0496-428e-85fc-58ac8eb37c29" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">To</gs> LR
        Sheets<gs id="6a918cf3-2946-4008-9245-1503c94b2ab0" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark"><gs id="4c8541da-97c1-4141-9096-9d34e5d59284" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs>"Trade Deal")<gs id="f8e11ba1-6f29-4376-9c10-a9762781a8ec" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark"><gs id="fb7eb380-3cf2-4933-ad74-b5f12d2e9264" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>Range<gs id="100b72e6-eaee-40aa-9f99-07992a79999d" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark"><gs id="1151b2fe-99ab-4d0a-93d4-204aaea91b2c" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs>"G6")<gs id="121f30dc-a8c3-4da0-bd09-d16b10782679" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark"><gs id="13c96a2f-4bb6-4576-8b4f-57f77bf5703e" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>Value =<gs id="54064ec1-8b23-47cb-ab4c-e92d7cd7340c" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark"><gs id="66075c2c-c477-4104-9608-006e7a2a2527" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark"> .</gs></gs>Range<gs id="b09261dd-942b-49d5-a848-e122be94571a" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark">(</gs>"A6" & <gs id="935e7043-0594-4090-b990-276d5151b894" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark">i</gs>)<gs id="f4797963-8662-4c5e-9ace-a47fe6202376" ginger_software_uiphraseguid="42187e2c-f4be-4371-9fe9-9122c1838b2f" class="GINGER_SOFTWARE_mark">.</gs>Value
        Sheets<gs id="c0e231a5-5dce-4dbd-9cfa-a6cb9e8b1305" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark">(</gs>"Trade Deal")<gs id="93b58eaf-8a12-467d-aa05-80d256819ca1" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark">.</gs>Range<gs id="f7c038b8-5379-4378-826b-c23a049e3ead" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark">(</gs>"B8")<gs id="15800c42-3f5b-4268-a71b-f123d576db24" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark">.</gs>Value =<gs id="91aa0099-3b72-4de3-8d75-5fd578c577c6" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark"> .</gs>Range<gs id="ea7fd875-c176-4a24-a34a-1d04e5c8795b" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark">(</gs>"C6" & <gs id="6e5307d9-4f04-42a2-88bb-ad4db6dbfdd4" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark">i</gs>)<gs id="305d0623-ce5f-4a8e-b714-2c906e359960" ginger_software_uiphraseguid="e4a1a817-d5d5-4563-b754-65bbe73d092c" class="GINGER_SOFTWARE_mark">.</gs>Value
        Sheets<gs id="913e062d-330d-4a35-b6ad-74e80c6488eb" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark">(</gs>"Trade Deal")<gs id="6e54f11f-a9a6-4693-b1ee-897a32b711e0" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark">.</gs>Range<gs id="a98efe68-0ea3-40de-b1c8-cae309b6df7e" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark">(</gs>"B9")<gs id="d28eb720-a3a1-4999-b583-5e6f9adaa9f5" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark">.</gs>Value =<gs id="02cfec05-34ae-4420-a2bc-74e1d9533c6c" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark"> .</gs>Range<gs id="76a32734-5812-4d9d-aa54-9433da4a5bf3" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark">(</gs>"E6" & <gs id="6f362a57-27fa-4a32-ba5e-bee925387add" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark">i</gs>)<gs id="b9c4feb5-04c4-4d4d-9b19-a0c4fe33fd91" ginger_software_uiphraseguid="6e2e92b7-ca96-4244-9aeb-528db8b06cdd" class="GINGER_SOFTWARE_mark">.</gs>Value
        Sheets<gs id="0b4c9b9d-f6bf-446b-9417-2e7e13f5db50" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark">(</gs>"Trade Deal")<gs id="2106c701-2350-41a3-bf7b-67717c4342a7" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark">.</gs>Range<gs id="a6b7dcf3-4f1d-4191-9057-c8a3f45307da" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark">(</gs>"F12")<gs id="0067b79f-ca54-4f01-bc7e-174c1442fc9f" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark">.</gs>Value =<gs id="783d1349-1b63-4f2f-a5e1-80b3dd63bb92" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark"> .</gs>Range<gs id="d7d052fe-2528-4226-ba5f-a20062cbabba" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark"><gs id="a0d19e47-0d99-4d45-8787-b21bc637e704" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs>"R6" & <gs id="f0929d16-c369-4ebf-9f54-35d77e526e09" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark"><gs id="7c1c78ae-4ebc-4594-93d3-a73ff1a073c1" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">i</gs></gs>)<gs id="8c3dcfb0-3d74-44ca-82b4-3289e69e14b7" ginger_software_uiphraseguid="7c2ae7ba-298e-4c72-aed5-0237eb3853d3" class="GINGER_SOFTWARE_mark"><gs id="136bbcbb-70e1-4103-9508-0b34ba8e39d8" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>Value
        Sheets<gs id="98096319-58f9-474d-a8ee-1fd0724d5985" ginger_software_uiphraseguid="15d764b3-0aff-4752-8dce-4a470a9352a2" class="GINGER_SOFTWARE_mark"><gs id="d23206fc-722b-414f-82ec-e44f1c751147" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">(</gs></gs>"Trade Deal")<gs id="f0aed977-bebe-424d-8b12-a77c70446a41" ginger_software_uiphraseguid="15d764b3-0aff-4752-8dce-4a470a9352a2" class="GINGER_SOFTWARE_mark"><gs id="34d0ad82-5c99-4a47-93a6-4eded5764805" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>PrintOut
    Next <gs id="87e74211-e9f8-487d-9570-62ce42af7e02" ginger_software_uiphraseguid="85194d43-0808-4cae-ba14-93326f5f1915" class="GINGER_SOFTWARE_mark"><gs id="ebc0950a-5929-4c01-8cb5-ab5635cee0ff" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">i</gs></gs>
End With
Application<gs id="a83bf0b6-0ec8-43d7-ac31-cba538e3b0f4" ginger_software_uiphraseguid="9fd7f0fd-1168-41d4-8592-d4f135f62e3d" class="GINGER_SOFTWARE_mark"><gs id="178aa607-361a-4644-8d7e-1809470a3f2a" ginger_software_uiphraseguid="1de4423f-d643-4701-93ab-9b63a0667f11" class="GINGER_SOFTWARE_mark">.</gs></gs>ScreenUpdating = True
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi cruspy,

the macro starts at A61

Yes because 6 & i = 61 (for the first loop). If you want to start at Row 6 you need to change the 1 in For i = 1 to LR to 6. You then need to adjust the row number being referenced like so:

Code:
.Range("A" & i).Value

But the way your code is currently written will result in the identified cells (G6, B8...) in the Trade Deal sheet being continually overwritten :confused:

prints two copies for some reason

As the code currently isn't instructing Excel to do that it must what the selected number of copies to print is (check it in print preview). This will force the issue:

Code:
Sheets("Trade Deal").PrintOut Copies:=1

HTH

Robert
 
Upvote 0
Thanks for the pointers! It's working great. The Trade Deal sheet is just a template that's continuously being fed with the data on the Test sheet, so it's how I wanted it to work.

Thanks again! :)
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top