Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Bob Bob is offline
external usenet poster
 
Posts: 972
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Bob Bob is offline
external usenet poster
 
Posts: 972
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to select a specific range based on the time value of user form input Jitranijam New Users to Excel 8 November 15th 06 12:52 AM
Conditional Format as a MACRO Gunjani Excel Worksheet Functions 3 March 29th 06 05:22 PM
More than 3 conditional formats? Ltat42a Excel Discussion (Misc queries) 12 January 6th 06 11:26 AM
Format cells with a formula (7 conditions). danindenver Excel Discussion (Misc queries) 3 January 2nd 06 02:40 PM
more than 3 conditions in conditional formatting - possible? rob curtis Excel Discussion (Misc queries) 11 August 17th 05 04:02 PM


All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"