VBA counter for labels per row

drag1c

New Member
Joined
Aug 7, 2019
Messages
10
Office Version
  1. 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:
Code:
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:
Code:
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
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Watch MrExcel Video

Forum statistics

Threads
1,127,420
Messages
5,624,695
Members
416,042
Latest member
Oden

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
Top