Consulting

Results 1 to 5 of 5

Thread: Solved: Setting the print area for used rows and columns

  1. #1

    Solved: Setting the print area for used rows and columns

    Hey once again all,

    Just encountered yet another problem.
    Im runing a macro where i want to set the printing area as all the used columns "A:L" and the rows "9:[lastrow]".

    My code is like this:
    [VBA]Dim y As Long, lastCell2 As range
    y = ActiveSheet.UsedRange.Rows.Count
    Set lastCell2 = Cells.SpecialCells(xlCellTypeLastCell)
    ActiveSheet.PageSetup.PrintArea = range(Cells(9, 1), lastCell2).Address
    [/VBA]

    but Im guessing that im missing the point here ...
    Anyone can help?!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Works fine for me. What is happening?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    sorry
    for me its marking all rows instead of stopping at the last one ...
    maybe its my sheet...

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    exactly - thnx!!

Posting Permissions

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