Excel Failure

tdurbin

New Member
Joined
Sep 16, 2002
Messages
6
First of all apologies, really simple query I think.

Anyway I have a lengthy spreadsheet that is being used as a customer order form. Each row after the top 39 is a different item. When I print it though, I only want to include the top 39 rows, rows that have an "x" in a certain cell, and the bottom 4 rows.

IS this possible? I am happy to pay for a fix, but it is quite urgent!

Cheers and here's hoping.

TD
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You could use a macro to hide the rows before printing. I'll have a go if you tell me:

1. The name of the sheet.
2. The rows you want to check (40 to ??).
3. Which column contains the "x".
 
Upvote 0
Mr Poulsom, you are a gentleman!

The sheet is called order and I need to keep the first 39 rows.

The column with the "x" is L, and the last 2 rows 322 & 323 need to be kept.

Let me know if this can be done, and thank you very much.

Cheers

Tom
 
Upvote 0
Try this:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Dim Rng As Range
    Dim c As Range
    If UCase(ActiveSheet.Name) <> "ORDER" Then Exit Sub
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Set Rng = Range("L40:L321")
    For Each c In Rng
        If UCase(c.Value) = "X" Then
            c.EntireRow.Hidden = True
        End If
    Next c
    Cancel = True
    ActiveSheet.PrintOut
    Rng.EntireRow.Hidden = False
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub

In case you're not familiar with macros, right click the XL logo to the left of File on the menu and choose View Code. Paste the code in the window on the right.

Then print your worksheet.
 
Upvote 0
Thank you so much for this.

Just to check, does it automatically run when I press the print icon, or do I have to run a macro?
 
Upvote 0
Thank you so much for this.

Just to check, does it automatically run when I press the print icon, or do I have to run a macro?
 
Upvote 0
All apologies, but I've followed your instructions to the letter and it doesn't seem to work....

Any chance I can e-mail you the sheet?

So sorry again and Thank you.

TD
 
Upvote 0

Forum statistics

Threads
1,213,522
Messages
6,114,112
Members
448,549
Latest member
brianhfield

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top