Results 1 to 3 of 3

Thread: How to use the code : Private Sub CommandButton1_Click()

  1. #1
    Join Date
    Nov 2011
    Posts
    58

    How to use the code : Private Sub CommandButton1_Click()

    How should the code be to use: Private Sub CommandButton1_Click()

    Code:
    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

  2. #2
    Join Date
    Nov 2010
    Posts
    503

    Re: How to use the code : Private Sub CommandButton1_Click()

    Is the commandbutton on sheet1. If yes then,
    Code:
    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:
    Code:
    Private Sub CommandButton1_Click()
    call Hide_Print_Unhide
    end sub

  3. #3
    Join Date
    Aug 2011
    Posts
    695

    Re: How to use the code : Private Sub CommandButton1_Click()

    There is another code that you can try :

    Code:
    Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, 
    
    ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long 
    Public Event ErrorDownload (FromPathName As String, ToPathName As String) 
     Public Event DownloadComplete (FromPathName As String, ToPathName As String) 
     Public Function DownloadFile (FromPathName As String, ToPathName As String) 
     If URLDownloadToFile (0, FromPathName, ToPathName, 0, 0) = 0 Then 
     DownloadFile = True 
     RaiseEvent DownloadComplete (FromPathName, ToPathName) 
     Else 
     DownloadFile = False 
     RaiseEvent ErrorDownload (FromPathName, ToPathName) 
     End If 
     End Function 
     Private Sub Command1_Click () 
     Call DownloadFile

Similar Threads

  1. Windows 7 Private Key Error
    By Phaedra in forum Windows Software
    Replies: 5
    Last Post: 07-01-2011, 07:42 PM
  2. What is the use of private constructor in C++?
    By Juaquine in forum Software Development
    Replies: 5
    Last Post: 05-03-2010, 04:41 PM
  3. What is a Virtual Private Network
    By Bindusar in forum Networking & Security
    Replies: 5
    Last Post: 20-12-2009, 06:39 AM
  4. How to unlock private folder
    By soloheart in forum Customize Desktop
    Replies: 2
    Last Post: 10-10-2009, 09:52 AM
  5. Private Bookmarking
    By mathews in forum Technology & Internet
    Replies: 3
    Last Post: 03-08-2009, 06:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,311,693.26631 seconds with 17 queries