Tuesday, July 7, 2015

Excel VBA

String:
  • chr(13) = change to the next line
  • _ =  break code to two lines


Function:

  • Transpose: Application.WorksheetFunction.Transpose()
  • Upper and lower bound: UBound() and LBound()
  • Join/concatenate: joins text, numbers, cell references, or a combination of those items into one text string
Range:
  • Range("B1:B10 , A4:D6").Select 选中两块不连续区域;
  • Range("B1:B10   A4:D6").Select 选中交叉的区域;
  • Range("B1:B10","A4:D6").Select 选中包含两块区域的最小矩形。


  • UsedRange: 所有使用过的单元格围成的区域;
  • Current Region: 所在的当前的区域;
  • Offset: 向下向右移动位置;
  • Range("A65536").End(xlUp).Offset(1,0): A列第一个非空的单元格;
  • Count: 单元格个数;
  • Address: 单元格位置;
  • Select, Activate
  • Clear, ClearContents, ClearComments, ClearFormats
  • Copy, Cut, Delete