Nov 27, 2007

memo of MS.Excel.VBA I

Purpose
 The purposes are written in blue words. 

Add sheet after the exists:
w = ActiveWorkbook.Worksheets.Count
'NOT "ThisWorkbook", USE "ActiveWorkBook" if it will be made as an Addin
Worksheets.Add After:=Worksheets(w)
Worksheets(w + 1).Name = "temp sheet"


Sort whole sheet according to one column:
Range(Cells(1, 1), Cells(iRow, iCol)).Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod:=xlPinYin, DataOption1:=xlSortNormal
'Range() to select whole sheet while Key1:=Range() to select the column


Check whether the Cell is empty, not null:
ActiveSheet.Cells(iRow, iCol) = Empty

Check whether cell's=listbox's content in a loop:
ActiveSheet.Cells(iRow, iCol) = Form.ListBox.List(k)

No comments: