Friday, 30 September 2011

Cell function to entire column (Trim / Upper / Lower....)

The below code will apply the cell level function to the entire column.


Dim r As Range
    Set r = Intersect(ShtTemp.Columns(4), ShtTemp.UsedRange)
    r.Value = Evaluate("IF(ROW(" & r.Address & "),IF(" & r.Address & "<>"""",UPPER(" & r.Address & "),""""))")
    r.Value = Evaluate("IF(ROW(" & r.Address & "),IF(" & r.Address & "<>"""",TRIM(" & r.Address & "),""""))")

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