Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks, all good.
"Héctor Miguel" wrote: hi, Andrew ! I have totally stuffed it :( This is what I have it does not have any effect on the print area and comes up with a warning 'Compile Error: Select Case eithout End Select". Can you please check it all out (does my named area 'Range' affect where you have "Range" ?) ... according to your comments for this recent post, you need only two codes: note that the use of LCase(...) vba-function is for not having to take care of text capitalization I preffer do a lowercase comparisson rather than case-sensitive capitalization (by default in vba) hth, hector. 1) in your workbook code module (ThisWorkbook) Private Sub Workbook_BeforePrint(Cancel As Boolean) If ActiveWindow.SelectedSheets.Count 1 Then _ Cancel = True: MsgBox "Please, select ONE (single) Sheet ONLY !" Select Case LCase(Range("ab1")) Case "internal" Cols2Hide = "p1" Rows2Hide = "a4" Case "external" Cols2Hide = "k1,l1" Rows2Hide = "a5" Case "feedback" Cols2Hide = "i1" Rows2Hide = "a4:a5" End Select If LCase(Range("ab1")) = "feedback" Then ActiveSheet.PageSetup.Orientation = xlPortrait ActiveSheet.PageSetup.CenterHeader = Range("ac1").Text Range(Cols2Hide).EntireColumn.Hidden = True Range(Rows2Hide).EntireRow.Hidden = True Range("a1").AutoFilter 1, Range("aa1").Text Application.OnTime Now, "Restore" End Sub 2) in a standard code module Option Private Module Sub Restore() ActiveSheet.PageSetup.Orientation = xlLandscape Range(Cols2Hide).EntireColumn.Hidden = False Range(Rows2Hide).EntireRow.Hidden = False Range("a1").AutoFilter End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using named range to extend print area for variable number of columns | Excel Worksheet Functions | |||
How do you set up a macro to reset the print area? | Excel Discussion (Misc queries) | |||
Pivot Table macro to set print area and print details of drill down data | Excel Discussion (Misc queries) | |||
Create a print macro that would automatically select print area? | Excel Worksheet Functions | |||
Variable print area | Excel Discussion (Misc queries) |