Macro to copy and paste a specified number of times

RICK150

New Member
Joined
Nov 9, 2005
Messages
44
Good day to you and thank you for looking into this.

I work in manufacturing. We have to produce labels for all the parts we build. As we have a new project starting i have a list of around 30 part numbers. For each part number i need to copy it twice in sheet 2 into cells A1 and A2. Cell A1 is already formatted into a barcode and cell a2 is formatted to a very small number in times new roman font. This produces a label which can be read by a handheld scanner and the operator.

Sheet 1 is more or less a simple request form. It has a drop down list of part numbers (B5) and a desired quantity to be printed (B6) it then has a hidden column (M) which splits cell B5 into 2 cells (M1 and M2) and runs a count (M4) which starts at 0.

Ultimately i would like to write a macro that when the user has selected their part number, quantity and hit button 1 the macro will copy cells M1 & M2 then copy and paster special (Values) into cells A1 and A2 on Sheet 2.

When its copied them into the first 2 cells it increases the count by 1 and checks it against the desired quantity. If its less then it copies them again but this time into cell A3 and A4 on sheet 2 and so on until the count (M5) matches the desired quantity (B6). Therefore if the user wanted 10 labels it should automatically fill from cell A1 to A20 in Sheet 2.

If anyone can help or you require further information regarding this then please let me know.

Thank you very much in advance for any help or support. And please feel free to recommend any changes to simplify (Eg. the loop until count(M5) = Desired quantity(B6)).

Ricky
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
So to try and simplify.

The user will enter a part number in cell B5 and their desired quantity in cell B6. All i want the Macro to do is copy Cell B5 and paste it into another column B5. The number of times it should loop through this is equal to the number entered in cell B6.

I'm sure its simple enough but this is my first Macro and journey into VBA and i'm struggling to program a Do Until loop myself. I might even be barking up the wrong tree using a Do until loop.

Thanks in advance, once again, for any help you can give me and if you're unable to help me then thanks for reading this post and trying. I've been using Mrexcel since 2005 to help me out of these little pickles and you guys have never let me down yet :D

Anyone have any idea at all?
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

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