PDA

View Full Version : Setting print area and borders.



Robert87
02-18-2014, 12:12 PM
Hello.

I have a slight problem at work.

I have a excel document where I put data in one column and several others fill in with the correct information.

What I want the VBA code to do:

Find the last cell in the column: AM with a value of atleast 1 and set a thick box border between that cell and B12. Then set printing range to the same cell and to B1.

So..

Thick Box Border = B12:last cell in AM with >1
Printing range = B1: last cell in AM with >1


After it has done that, could it print that sheet, change to a sheet named Listor, and print that one too.


This would be very appreciated.

westconn1
02-19-2014, 04:48 AM
you can try like

Set lastcell = Cells(Rows.Count, "AM").End(xlUp)
For rw = 0 To lastcell.Row
If lastcell.Offset(rw) > 1 Then Set lastcell = lastcell.Offset(rw): Exit For
Next
Range(Cells(12, 2), lastcell).BorderAround , xlThick
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 2), lastcell).Address
ActiveSheet.PrintOut
Sheets("listor").PrintOut

p45cal
02-19-2014, 07:49 AM
should:
If lastcell.Offset(rw) > 1 Then Set lastcell = lastcell.Offset(rw): Exit For
perhaps be:
If lastcell.Offset(-rw) >= 1 Then Set lastcell = lastcell.Offset(-rw): Exit For

westconn1
02-20-2014, 01:45 AM
looks like, though
Thick Box Border = B12:last cell in AM with >1

p45cal
02-20-2014, 02:46 AM
looks like, thoughThe OP doesn't seem to be very sure either:
with a value of atleast 1 and:and
with >1

Robert87
02-24-2014, 04:55 AM
The OP doesn't seem to be very sure either:and

Ohh sorry. It should be >1.