Sub AveryLabels5163()
'''' Print onto Avery Compatible 5163 labels (2" x 4")
'''' Caveat: You may need to adjust row height/column width and/or margins to fit your labels
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim LastRow As Long, i As Long, j As Long, NoCols As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Filtur As String
Dim prtArea As Range
Set ws1 = ActiveSheet
Set ws2 = Sheets.Add(after:=Worksheets(Worksheets.Count))
LastRow = ws1.Cells(Rows.Count, "A").End(xlUp).Row
Filtur = InputBox("Please Enter Filter Criterion")
'''' Filter and copy data to new sheet
On Error GoTo errHandler:
With ws1
.AutoFilterMode = False
.Range("A1:G1").AutoFilter
.Range("A1:G1").AutoFilter Field:=1, Criteria1:=Filtur
.Range("B2:G" & LastRow).SpecialCells(xlCellTypeVisible).Copy ws2.Range("B1")
.AutoFilterMode = False
End With
'''' Concatenate data to Column A
LastRow = ws2.Cells(Rows.Count, "B").End(xlUp).Row
With ws2
For i = 1 To LastRow
.Cells(i, 1) = .Cells(i, 2) & vbCrLf & .Cells(i, 3) & vbCrLf & _
.Cells(i, 4) & vbCrLf & .Cells(i, 5) & vbCrLf & _
.Cells(i, 6) & vbCrLf & .Cells(i, 7)
.Cells(i, 1).Value = Cells(i, 1).Value
Next i
Columns("B:G").Delete
End With
'''' Resize to two across
j = 1
NoCols = 2
For i = 1 To LastRow Step NoCols
ws2.Cells(j, "A").Resize(1, NoCols).Value = _
Application.Transpose(ws2.Cells(i, "A").Resize(NoCols, 1))
j = j + 1
Next
Range(ws2.Cells(j, "A"), ws2.Cells(LastRow, "A")).Clear
LastRow = ws2.Cells(Rows.Count, "A").End(xlUp).Row
Set prtArea = ws2.Range("A1:C" & LastRow)
'''' Format cells
With ws2.Cells
.RowHeight = 144 'Adjust as necessary
.ColumnWidth = 54.57 'Adjust as necessary
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
End With
'''' Set Print Settings
Application.PrintCommunication = False
With ws2.PageSetup
.LeftMargin = Application.InchesToPoints(0.01) 'Adjust as necessary
.RightMargin = Application.InchesToPoints(0.01) 'Adjust as necessary
.TopMargin = Application.InchesToPoints(0.5) 'Adjust as necessary
.BottomMargin = Application.InchesToPoints(0.5) 'Adjust as necessary
.Orientation = xlPortrait
.PaperSize = xlPaperLetter
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintArea = prtArea.Address
End With
Application.PrintCommunication = True
Range("A1").Select
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Exit Sub
errHandler:
ws1.AutoFilterMode = False
ws2.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Sorry, your filter criterion did not find a match." & vbCrLf & _
"Please try again."
End Sub