Wednesday, 22 June 2011

Hide Excel - When loading Userform

This code will hide the excel workbook when the form load. Copy the below code to Userform module. Write Userform.show in the Workbook open event.


Private m_lngLeft As Long
Private m_lngTop As Long
Private m_lngWindowState As Long


Private Sub Hide_excel()
    Application.Visible = Not Application.Visible
End Sub


Private Sub UserForm_Initialize()
    Application.WindowState = xlMaximized
    m_lngWindowState = Application.WindowState
End Sub


Private Sub UserForm_Terminate()
    Application.Visible = true
    Application.WindowState = m_lngWindowState
End Sub

Saturday, 18 June 2011

List all worksheet names

The below code will list down all the worksheet names even thought the sheet has been hidden.


Sub SheetNames()
    For i = 1 To Sheets.Count
    Cells(i, 1) = Sheets(i).Name
    Next i
End Sub