liangx85

VBA操作单元格

行或列的Group化

ws.Rows("row1:row2").group

row1:Group化的开始行                row2:Group化的结束行

ws.Columns("cln1:cln2").group

cln1:Group化的开始列                  cln2:Group化的结束列

Group化行或列的收缩和展开

ExecuteExcel4Macro "SHOW.DETAIL(1,x,FALSE,y)"

FALSE:收缩           TRUE:展开

x:结束位置             y:开始位置前一行或列

 

最后非空行或列

ws.cells(row,column).End(xiUp / xlToLeft)

 

工作表内检索

dim rngInfos as Range

dim first as string

With ws.range("B:B")

  set rngInfos = .Find(What:=string, LookIn:=xlValue,LookAt:=xlPart / xlWhole, SearchDirection:=xlNext)

     if not rngInfos is nothing then

     first = rngInfos.Address

         Do

     详细处理。。。

              set rngInfos = .FindNext(rangInfos)

         Loop While Not rangInfos is nothing and rngInfos.Address <> first

  end if

end with

 

单元格注释追加

①Range("A1").AddComennts "Comments"

②With Range("A1")

         .AddComments

         .Comment.Visible = False

         .Comment.Text "Comments"

   End With

 

工作表移动

Sheets(2).select

Sheets(2).Move  Before:=Sheets(1)

Before: 向前移动             After:向后移动

 

单元格复制

①Range("A1").Copy

   Range("B1").Paste

②Range("A1").copy  Range("B1")

 

单元格截取粘贴

Range("A1").Cut  Range("B1")

 

行或列的追加

ws.Range("M:M").Insert Shift:=xlToRight

 

单元格结合

ws.Range("B2:C3").Merge  

posted on 2014-01-08 13:54  liangx85  阅读(556)  评论(0编辑  收藏  举报

导航