Results 1 to 4 of 4

Thread: Trouble with Range objects in For Each...Next loops

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
     
    Sub SetPrintArea() 
        ' Declarations
        Dim lastCell As Range 
        Dim i As Integer 
        ' Code
        for i = 1 to ActiveWorkbook.Sheets.Count
            With ActiveWorkbook.Sheets(i)
                Set lastCell = Cells.SpecialCells(xlCellTypeLastCell) 
                sht.PageSetup.PrintArea = Range(Cells(1, 2), lastCell).Address 
                Set lastCell = Nothing
            End With
        next i
    Last edited by Aussiebear; 02-08-2025 at 09:51 AM.

Posting Permissions

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