VBA counter for labels per row

drag1c

Board Regular
Joined
Aug 7, 2019
Messages
92
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hello guys,

I used code already existed and changed it for my needs but I have troubles with adding function for counting how many labels per each row will be printed with zebra printer.

Here below is picture of table (Table6) which I am using as data.

Label is on different sheet:


VBA Code is below:
PHP:
Sub Print_Labels()
Dim c As Range, Printer As Variant, Printers As Variant, cPrinter As String, AbortPrintIf MsgBox("Are you sure you want to print " & [Table6[ITEM]].Count & " Labels for " & Range("F1").Value & " Invoice?", vbQuestion + vbYesNo) = vbYes ThenApplication.ScreenUpdating = False    cPrinter = ActivePrinter    Printers = GetPrintersAndPorts        For Each Printer In Printers        If InStr(Printer, "MSP-Label2") Then            Application.ActivePrinter = Printer: Exit For        End If    Next Printer            If Not InStr(ActivePrinter, "MSP-Label2") Then            If MsgBox("Specified Label printer not found!" & vbCrLf & "Do you want to  print to " & ActivePrinter & " ?", vbExclamation + vbYesNo) <> vbYes Then                GoTo AbortPrint            End If        End If            For Each c In [Table6[N.BOX]]        With Sheets("Label")              .[E5] = Range("B2")              .[E2] = Intersect(c.EntireRow, [Table6[ITEM]])              .[E3] = Intersect(c.EntireRow, [Table6[QTY/BOX]])        End With                        ThisWorkbook.Worksheets("Label").PrintOut    NextAbortPrint:    Application.ActivePrinter = cPrinter    Application.ScreenUpdating = TrueEnd If
End Sub
Code is working fine for whole table but it prints just 1 label. It should follow Table6 Column named N.BOX.
I have tried with Range function but it works only for one row. I do not know how to include whole column.
It was like:
PHP:
For a = 1 to Range("D5").Value etc...
... but at the end I deleted it since it is not working properly.

Does anyone have solution how I can print whole list of labels by counting also N.BOX column in table?

Thanks in advance !

Djordje
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

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