+ Reply to Thread
Results 1 to 3 of 3

Please help with passing values

  1. #1
    Registered User
    Join Date
    09-02-2005
    Posts
    6

    Please help with passing values

    Hi,

    Below is a snippet of code which I found in some Excel forum and I have used previously to determine the print range of a list.

    For some reason this code does not seem to work anymore and it seems to have something to do with the passing of arguments??

    Any help would be REALLY appreciated!!

    Please Login or Register  to view this content.

  2. #2
    ste
    Guest

    Re: Please help with passing values

    hi, try this:

    Sub PrintSchedule()
    'This procedure executes when the user clicks the Print Schedule
    button and print
    'previews all the expense schedule.

    Dim PrintThis As Range
    'Dim sh As Worksheet
    frmWait.Show 0
    frmWait.Repaint
    Worksheets("Expense Schedule").Activate
    'Application.ScreenUpdating = False
    'Application.ScreenUpdating = True

    'PrintThis = ActiveSheet.Range("A20:P" &
    LastRowRange(ActiveSheet)).Address
    Set PrintThis = ActiveSheet.Range("A20:P" & LastRowRange(ActiveSheet))
    '<

    frmWait.Hide
    With Worksheets("Expense Schedule").PageSetup
    If .TopMargin <> Application.InchesToPoints(0.5) Then
    .TopMargin = Application.InchesToPoints(0.5)
    End If
    .PrintTitleRows = Worksheets("Expense
    Schedule").Range("A20:A21").Address

    ..PrintArea = PrintThis.Address '<

    .Orientation = xlLandscape
    .CenterHeader = ""
    .BlackAndWhite = True
    If .CenterHeader <> "" Then .CenterHeader = ""
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 100
    End With
    Worksheets("Expense Schedule").PrintPreview
    Worksheets("Help").Activate
    Worksheets("Inv Summ").Activate
    Range("A1").Select


    End Sub




    'Function LastRowRange(sh As Worksheet)
    Function LastRowRange(sh As Worksheet) As Long '<
    'This function determines the active print
    'range for a list and returns a range object.

    'On Error Resume Next
    ' LastRowRange = sh.Range("A:P").Find(What:="*", _
    After:=sh.Range("A21"), _
    Lookat:=xlPart, _
    LookIn:=xlFormulas, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious, _
    MatchCase:=False) .Row


    LastRowRange =
    Range("P20").CurrentRegion.SpecialCells(xlCellTypeLastCell).Row


    'On Error GoTo 0


    End Function



    Regards,
    ste


  3. #3
    Registered User
    Join Date
    09-02-2005
    Posts
    6

    Thanks ste

    Thanks for the response!

+ 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