Printing, VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top