+ Reply to Thread
Results 1 to 2 of 2

Count number of cells & Page Setup

  1. #1
    jhahes
    Guest

    Count number of cells & Page Setup

    Could someone please help me with the following....

    I only have data in column a.....

    how do I count the number of cells in column a that have data in them, starting in the range a4:A500.....all cells that have data will be consecutive, no blank cells between data.


    With that information I would like to code a page setup print area....

    my current code is this

    ActiveSheet.PageSetup.PrintArea = "$A$1:$A$500"
    however, I want print area to be a1 to the last column that has data, not 500, unless 500 is the last column with data...

    thank you for any help

    Josh

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    josh

    try

    Sub SetPrintArea()
    Dim lLastRow As Long

    lLastRow = Cells(Rows.Count, "a").End(xlUp).Row
    ActiveSheet.PageSetup.PrintArea = "a1:a" & lLastRow
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1