I have a worksheet that's formatted to print out on a long, 1 inch-wide strip of adhesive label tape. The range of potentially printable cells goes from A1 to CF6.
All of the cells in this range have conditional formulas in them to either pull criteria from another sheet in the file, or to be blank, i.e.:
=IF('list'!$M371="","",'list'!$M371)
I'm trying to create a macro that will set the print area to include only cells that don't equal "", then print. I have searched many excel boards and found nothing that will work. I've also tried changing the "" to 0. (This didn't work either, and also messed up the concatenate function I'm using in one of the rows.)
Right now I'm using this, but it still selects A1 to CF6 when I run it:
========
Sub SelectLabels()
Dim lastCell As Range
Set lastCell = Cells.SpecialCells(xlCellTypeLastCell).Offset(0, 1)
Do Until Application.Count(lastCell.EntireRow) <> ""
Set lastCell = lastCell.Offset(-1, 0)
Loop
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address
End Sub
===========
Can anyone give me a clue?
Thanks in advance.
All of the cells in this range have conditional formulas in them to either pull criteria from another sheet in the file, or to be blank, i.e.:
=IF('list'!$M371="","",'list'!$M371)
I'm trying to create a macro that will set the print area to include only cells that don't equal "", then print. I have searched many excel boards and found nothing that will work. I've also tried changing the "" to 0. (This didn't work either, and also messed up the concatenate function I'm using in one of the rows.)
Right now I'm using this, but it still selects A1 to CF6 when I run it:
========
Sub SelectLabels()
Dim lastCell As Range
Set lastCell = Cells.SpecialCells(xlCellTypeLastCell).Offset(0, 1)
Do Until Application.Count(lastCell.EntireRow) <> ""
Set lastCell = lastCell.Offset(-1, 0)
Loop
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), lastCell).Address
End Sub
===========
Can anyone give me a clue?
Thanks in advance.