资源描述:
《excel vba常用技巧代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1.删除重复行12.ActiveX控件的相关操作23.单元格内容匹配24.单元格填充公式35.弹出打开对话框36.操作文件夹下的所有工作簿37.获取数据区域的最后一行和最后一列48.获取列的字母顺序[A~IV]49.自定义函数返回数组并填充至单元格区域410.绘制曲线图511.单元格区域拷贝612.操纵数据库(查、增、删、改)613.待定XX71.删除重复行关键字:[a65536].End(xlUp).Row、Offset()、相关双层循环SubRemoveDuplicate()'删除重复行Fori=[a65536].End(xlUp
2、).Row-1To1Step-1'按倒叙删除Forj=[a65536].End(xlUp).RowToi+1Step-1IfCells(i,1).Value=Cells(j,1).ValueThenRows(i).DeleteEndIfNextNextEndSubSubRemoveItem()'删除相邻重复,但不删除隔行重复DimiAsLongWithRange("A2")'以A2为基准进行单元格偏移DoWhile.Offset(i,0)If.Offset(i,0).Value=.Offset(i-1,0).ValueThen.Off
3、set(i,0).EntireRow.Deletei=i+1LoopEndWithEndSubbeconsistentwithinthesamedisk.Alternateunifiedcorerequirementsplacedontheterminalstripterminals,onlineidentityandensurethecoppercoreisnotexposed.6.4.6enclosurewithinthesametothecablecoreprovidesbindingintoacircle,harnesstie
4、spacingisgenerally100mm;branchofficesshallbebindingonbothends,eachcore1.ActiveX控件的相关操作关键字:ActiveX、OLEObjects、ActiveSheet.OLEObjects遍历控件DimcAsObjectForEachcInActiveSheet.OLEObjectsIfc.Name="ComboBox"&iThen'…………..ElseIfc.Name="CheckBox"&iThen'…………..EndIfNextc附件:2.单元格内容匹配关
5、键字:ExitFor、.Interior.ColorIndex、互不相关双层循环SubMatch()Dimi,jAsIntegerFori=1To[a65536].End(xlUp).RowForj=1To[b65536].End(xlUp).RowIfCells(i,1).Value=Cells(j,2).ValueThenCells(i,1).Interior.ColorIndex=j+iCells(j,2).Interior.ColorIndex=j+iExitFor'仅匹配第一次EndIfNextjNextiEndSubSub
6、UnMatch()Dimi,jAsIntegerFori=1To[F65536].End(xlUp).RowForj=1To[G65536].End(xlUp).RowIfCells(i,6).Value=Cells(j,7).ValueThenExitFor'当找到有匹配的时候退出,进入下一个记录查找Else'当找遍所有,但未找到(j=循环上限),给出处理beconsistentwithinthesamedisk.Alternateunifiedcorerequirementsplacedontheterminalstripterm
7、inals,onlineidentityandensurethecoppercoreisnotexposed.6.4.6enclosurewithinthesametothecablecoreprovidesbindingintoacircle,harnesstiespacingisgenerally100mm;branchofficesshallbebindingonbothends,eachcoreIfj=[G65536].End(xlUp).RowThenCells(i,6).Interior.ColorIndex=j+iEnd
8、IfEndIfNextjNexti附件:1.单元格填充公式关键字:公式、.Formula、.FormulaR1C1Cells(1,1).Formula="=B1+C1"Cells(2,1).FormulaR1C1="=R