资源描述:
《excel中vba常见函数(common functions of vba in excel)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、excel中vba常见函数(CommonfunctionsofVBAinExcel)示例如下,instr函数的使用DimSTRasstringForI=1tocountrows(1)STR=cells(I,5)Ifinstr(1,STR,"东风)<>0thenCells(I,5).SelectSelection.font.colorindex=3EndifNextIExcelvba字符串转换函数来源:原创点击数:1767评论数:1评论
2、收藏
3、复制时间:2011-10-1810:34:29作者:欢乐小爪摘要:VBA字符串转换函数正文:1.vba字符串函数列表:去掉string左右两端空白trim
4、(string)去掉string左端空白ltrim(string)去掉string右端空白rtrim(string)Len(string)计算string长度Left(string,x)取string左段x个字符组成的字符串Right(string,x)取string右段x个字符组成的字符串Mid(string,start,x)取string从start位开始的x个字符组成的字符串Ucase(string)转换为大写转换为小写lcase(string)Space(x)返回x个空白的字符串ASC(string)返回一个integer,代表字符串中首字母的字符代码Chr(charcode)返回st
5、ring,其中包含有与指定的字符代码相关的字符2,vba转换函数列表:CBool(expression)isconvertedtoBooleantypeCByte(expression)isconvertedtoBytetypeCCur(expression)isconvertedtoCurrencytypeCDate(expression)isconvertedtoDatetypeCDbl(expression)isconvertedtoDoubletypeCDec(expression)isconvertedtoDecemaltypeCInt(expression)isconvertedt
6、oIntegertypeCLng(expression)isconvertedtoLongtypeCSng(expression)isconvertedtoSingletypeCStr(expression)isconvertedtoStringtypeCVar(expression)isconvertedtoVarianttypeVal(string)isconvertedtodatatypeStr(number)isconvertedtoString3,VBAtimefunction:NowreturnsaVariant(Date)andspecifiesthedateandtimeacc
7、ordingtothedateandtimesetbythecomputersystem.DatereturnstheVariant(Date)containingthedateofthesystem.TimereturnsaVariant(Date)thatspecifiesthecurrentsystemtime.TimerreturnsaSingle,representingthenumberofsecondsfrommidnighttonow.TimeSerial(hour,minute,second)returnsaVariant(Date)thatcontainstime,minu
8、tes,andseconds.DateDiff(interval,date1,date2[,firstdayofweek[,firstweekofyear]])returnsthevalueofVariant(Long),indicatingthenumberoftimeintervalsbetweentwospecifieddatesSecond(time)returnsaVariant(Integer)whoseintegervaluesarebetween0and59,RepresentsasecondinaminuteMinute(time)returnsaVariant(Intege
9、r),whichisanintegerbetween0and59,representingaminuteinanhourHour(time)returnsaVariant(Integer),whichisanintegerbetween0and23,representinganhourinthedayDay(date)returnsaVariant(Integer),whichisanintege