Consulting

Results 1 to 6 of 6

Thread: Setting print area and borders.

  1. #1
    VBAX Regular
    Joined
    Dec 2013
    Posts
    25
    Location

    Setting print area and borders.

    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.

  2. #2
    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

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    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
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    looks like, though
    Thick Box Border = B12:last cell in AM with >1

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Quote Originally Posted by westconn1 View Post
    looks like, though
    The OP doesn't seem to be very sure either:
    Quote Originally Posted by Robert87 View Post
    with a value of atleast 1 and:
    and
    Quote Originally Posted by Robert87 View Post
    with >1

  6. #6
    VBAX Regular
    Joined
    Dec 2013
    Posts
    25
    Location
    Quote Originally Posted by p45cal View Post
    The OP doesn't seem to be very sure either:and
    Ohh sorry. It should be >1.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •