+ Reply to Thread
Results 1 to 3 of 3

Printing, VBA

  1. #1
    Denys
    Guest

    Printing, VBA

    Good day everyone,

    With the following code, Excel only prints the rows where the date is in
    2005. I wish to print everything prior to todays's date, including 2004....
    Here's the code:

    Dim herrange As Range
    Dim Mydate As Date
    Mydate = Date
    With Worksheets("Database")
    .Range("E2").Select
    Set herrange = .Range("PasseDue")
    For Each cell In herrange
    If cell.Value < Mydate And ActiveCell.Offset(,
    104).Value > 0 Then
    Call ImprimerAllPastDue
    End If
    ActiveCell.Offset(1, 0).Select
    Next

    Do you have any clue of what could be wrong?

    Thanks for your time

    Denys


  2. #2
    Tom Ogilvy
    Guest

    Re: Printing, VBA

    Perhaps your cells are not really dates, but text strings that look like
    dates.

    Dim herrange As Range
    Dim Mydate As Date
    Mydate = Date
    With Worksheets("Database")
    Set herrange = .Range("PasseDue")
    For Each cell In herrange
    cell.Select
    if isdate(cell.Value) then
    If cDate(cell.Value) < Mydate And _
    ActiveCell.Offset(, 104).Value > 0 Then
    Call ImprimerAllPastDue
    End If
    Next
    End With
    End Sub

    Then it could have something to do with what happens in the mysterious
    ImprimerAllPastDue
    Or the ActiveCell.offset(,104).Value isn't greater than zero for dates in
    2004

    --
    Regards,
    Tom Ogilvy

    "Denys" <[email protected]> wrote in message
    news:[email protected]...
    > Good day everyone,
    >
    > With the following code, Excel only prints the rows where the date is in
    > 2005. I wish to print everything prior to todays's date, including

    2004....
    > Here's the code:
    >
    > Dim herrange As Range
    > Dim Mydate As Date
    > Mydate = Date
    > With Worksheets("Database")
    > .Range("E2").Select
    > Set herrange = .Range("PasseDue")
    > For Each cell In herrange
    > If cell.Value < Mydate And ActiveCell.Offset(,
    > 104).Value > 0 Then
    > Call ImprimerAllPastDue
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Next
    >
    > Do you have any clue of what could be wrong?
    >
    > Thanks for your time
    >
    > Denys
    >




  3. #3
    K Dales
    Guest

    RE: Printing, VBA

    The code looks OK, so how are you setting the cell values? What about
    ActiveCell.Offset(,104) - what is in there, since this also determines if the
    print routine is called?

    "Denys" wrote:

    > Good day everyone,
    >
    > With the following code, Excel only prints the rows where the date is in
    > 2005. I wish to print everything prior to todays's date, including 2004....
    > Here's the code:
    >
    > Dim herrange As Range
    > Dim Mydate As Date
    > Mydate = Date
    > With Worksheets("Database")
    > .Range("E2").Select
    > Set herrange = .Range("PasseDue")
    > For Each cell In herrange
    > If cell.Value < Mydate And ActiveCell.Offset(,
    > 104).Value > 0 Then
    > Call ImprimerAllPastDue
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Next
    >
    > Do you have any clue of what could be wrong?
    >
    > Thanks for your time
    >
    > Denys
    >


+ 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