Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Private Sub CommandButton1_Click()
How should the code be to use:
Private Sub CommandButton1_Click() To run this: Sub Hide_Print_Unhide() Dim rw As Long Application.ScreenUpdating = False With Sheets("Sheet1") For rw = 1 To 30 If .Cells(rw, "A").Value = "" Then _ .Rows(rw).Hidden = True Next rw .PrintOut ' for testing use .PrintPreview .Range("A1:A30").EntireRow.Hidden = False End With Application.ScreenUpdating = True End Sub Thanks Bob |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Private Sub CommandButton1_Click()
Is the commandbutton on sheet1?
If yes: Private Sub CommandButton1_Click() Dim rw As Long Application.ScreenUpdating = False 'Me is the object that owns the code 'in this case Sheet1 With Me 'Sheets("Sheet1") For rw = 1 To 30 If .Cells(rw, "A").Value = "" Then _ .Rows(rw).Hidden = True Next rw .PrintOut ' for testing use .PrintPreview .Range("A1:A30").EntireRow.Hidden = False End With Application.ScreenUpdating = True End Sub Another option would be to just call that same routine: Private Sub CommandButton1_Click() call Hide_Print_Unhide end sub Bob wrote: How should the code be to use: Private Sub CommandButton1_Click() To run this: Sub Hide_Print_Unhide() Dim rw As Long Application.ScreenUpdating = False With Sheets("Sheet1") For rw = 1 To 30 If .Cells(rw, "A").Value = "" Then _ .Rows(rw).Hidden = True Next rw .PrintOut ' for testing use .PrintPreview .Range("A1:A30").EntireRow.Hidden = False End With Application.ScreenUpdating = True End Sub Thanks Bob -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Private Sub CommandButton1_Click()
Thanks Dave, works fine.
"Dave Peterson" wrote: Is the commandbutton on sheet1? If yes: Private Sub CommandButton1_Click() Dim rw As Long Application.ScreenUpdating = False 'Me is the object that owns the code 'in this case Sheet1 With Me 'Sheets("Sheet1") For rw = 1 To 30 If .Cells(rw, "A").Value = "" Then _ .Rows(rw).Hidden = True Next rw .PrintOut ' for testing use .PrintPreview .Range("A1:A30").EntireRow.Hidden = False End With Application.ScreenUpdating = True End Sub Another option would be to just call that same routine: Private Sub CommandButton1_Click() call Hide_Print_Unhide end sub Bob wrote: How should the code be to use: Private Sub CommandButton1_Click() To run this: Sub Hide_Print_Unhide() Dim rw As Long Application.ScreenUpdating = False With Sheets("Sheet1") For rw = 1 To 30 If .Cells(rw, "A").Value = "" Then _ .Rows(rw).Hidden = True Next rw .PrintOut ' for testing use .PrintPreview .Range("A1:A30").EntireRow.Hidden = False End With Application.ScreenUpdating = True End Sub Thanks Bob -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Trying to select a specific range based on the time value of user form input | New Users to Excel | |||
Conditional Format as a MACRO | Excel Worksheet Functions | |||
More than 3 conditional formats? | Excel Discussion (Misc queries) | |||
Format cells with a formula (7 conditions). | Excel Discussion (Misc queries) | |||
more than 3 conditions in conditional formatting - possible? | Excel Discussion (Misc queries) |