Macro to change value from list and make number of copies by cell value then print all pages

Radzha

New Member
Joined
Oct 11, 2017
Messages
2
Hello,

I am trying to optimize paperwork and I cant figure out how to compile two separate macros to work as I need.

On Excel worrk book I have two sheets.

Sheet1 contains order form (invoice, etc.)
Sheet2 contains list of product name and quantity.

I need to do a macro so it would take "Product name" from list(eg. Sheet2 A1 to Sheet1 N10) and change number interchangeable from 1 to "Quantity" (eg. Sheet2 B2 to Sheet1 R10) and print all generated copies through all the list

For example: Sheet2 contains product "TEST" and quantity is "3". So printout will be 3 pages "TEST - 1", "TEST - 2", 'TEST - 3" And then folow to the next value in the list.


Thank for tips.


I have found a way to print number of copies with interchangeable number using this code below.

Code:
Sub Technologiniu_korteliu_kiekis()

Dim CopiesCount As Long
Dim copynumber As Long


CopiesCount = Application.InputBox("How many copies do you want?", Type:=1)
'Now the program wants you to input how many pages you like to print.
'You can input 100 here.


For copynumber = 1 To CopiesCount
With ActiveSheet
   .Range("L7").Value = copynumber 'I assume your invoice number is in cell E1.
   .PrintOut 'Print the sheet
End With
Next copynumber
End Sub

Thread in tihs forum called "VBA macro for REPLACE cell value from a list THEN print! Important :)" has macro for replacing values. So I wonder how to merge these codes?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hello,

It seems I have managed to compile those codes togethers. So far it works as intended.

Code:
Sub Macro()

Dim i As Long, LastRow As Long


LastRow = Worksheets("Sheet2").Range("C65536").End(xlUp).Row


For i = 8 To LastRow


    Worksheets("Sheet1").Range("G6").Value = Worksheets("Sheet2").Range("C" & i).Value
    Worksheets("Sheet1").Range("J7").Value = Worksheets("Sheet2").Range("D" & i).Value


Dim CopiesCount As Long
Dim copynumber As Long


CopiesCount = Worksheets("Sheet2").Range("E" & i).Value


If Not Worksheets("Sheet2").Range("B" & i).Value = 1 Then
For copynumber = 1 To CopiesCount
With Worksheets("Sheet1")
   .Range("L7").Value = copynumber
   .PrintOut
End With
Next copynumber
    End If


Next i




End Sub
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

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