Gizmo-helten
New Member
- Joined
- Sep 17, 2006
- Messages
- 9
I have a sheet where information can be put in 20 areas. An area covers 19 rows and if there is put data in one of the areas it should be printed. I can put three areas in a single A4-page. The problem is that when I press the print button in the toolbar it prints the entire sheet, and I have tried experimenting with a macro that should check for which areas that are data in and print them out. But I can´t get it to work, can anyone please help me???
My printOut code looks like this, but nothing happens at all???
This first area is an area that calculates all the areas together, and should be put alone on the first printed page...
If I54 > "" Then
Range("$C$10:$J$32").Select
Selection.PrintOut
End If
If I54 > 0 Then
Range("$C$35:$J$54").Select
Selection.PrintOut
End If
If I75 > 0 Then
Range("$C$56:$J$75").Select
Selection.PrintOut
End If
If I96 > 0 Then
Range("$C$98:$J$117").Select
Selection.PrintOut
End If
And so it continous 20 times
I also have tried this code:
Private Sub CommandButton2_Click()
If I36 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J54").PrintOut
ElseIf I58 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J78").PrintOut
ElseIf I79 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J97").PrintOut
End If
End Sub
My printOut code looks like this, but nothing happens at all???
This first area is an area that calculates all the areas together, and should be put alone on the first printed page...
If I54 > "" Then
Range("$C$10:$J$32").Select
Selection.PrintOut
End If
If I54 > 0 Then
Range("$C$35:$J$54").Select
Selection.PrintOut
End If
If I75 > 0 Then
Range("$C$56:$J$75").Select
Selection.PrintOut
End If
If I96 > 0 Then
Range("$C$98:$J$117").Select
Selection.PrintOut
End If
And so it continous 20 times
I also have tried this code:
Private Sub CommandButton2_Click()
If I36 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J54").PrintOut
ElseIf I58 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J78").PrintOut
ElseIf I79 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J97").PrintOut
End If
End Sub