在帮助文件里还有hour;minute;second不再范围情况,这时候,如何计算的呢? 1、second/60;除的整数为minute;mod(second;60)为second 2、minute/60,除的整数为hour;mod(minute;60)为minute 3、hour/24,mod(hour;24)为hour 最后再用hour/24+minute/(24*60)+second/ (24*60*60)计算。 帮助中的例子:time(0;0;2000)=0。023148如何算的呢? 2000/60=33 mod(2000;60)=20 time(0;0;2000)=time(0;33;20)=0/24+33/(24*60)=20/(24*60*60)=0。023148 呵呵,其实没有什么用,会用这个函数就可以可,如何算的就不必在意了!!! 033。年月日的问题 EXCEL表格中年月有时候输入不对,(早已记录过大量数据,改写麻烦。)比如198001,意 思是1980年1月,可是设置单元格式日期只有年月日,没有年月。怎么做? 解 答 : 插 入 一 辅 助 列 , 假 设 198001 在 E1 , F=IF(MID(E1;5;1)=〃0〃;LEFT(E1;4)&〃 年 〃&RIGHT(E1;1)&〃月〃;LEFT(E1;4)&〃年〃&RIGHT(E1;2)&〃月〃) 试一下。 又问:198001能否改为1980…1?或者1980年1月改为1980…1? 解答:f1=IF(MID(e1;5;1)=〃0〃;LEFT(e1;4)&〃…〃&RIGHT(e1;1);LEFT(e1;4)&〃…〃&RIGHT(e1;2)) 或者更简单一些:=LEFT(A6;4)&〃…〃&value(RIGHT(A6;2)) (数据在a6单元格) 也可以这样:=date(mid(e1;1;4);mdi(e1;5;2);1)这样会显示为1980…1…1,然后可以随意设置成 相应的日期格式。 034。请帮忙解释一个公式 =LEFT(A1;(SEARCHB(〃?〃;A1)…1)/2)这是我在站内过去的帖子里看到的一个公式,用于提取前 文后数中的文字部分,非常好用。请教这个公式中最后两步的意义是什么?另外,当A1是“ 1234 个”的格式时,当如何提取其中的文字呢? 解答:1、公式的含义是:查找第一个半角字符出现的位置'SEARCHB(〃?〃;A1)',减去1后除以 2,就是文字的字符数目,将其提取出来。 2、=RIGHT(A1;LENB(A1)…LEN(A1)) 035。关于宏和程序 我现在已经用excel编了一个较完整的程序,并且能够给源程序加密码,实现〃工程不可见〃, 但是我发现在vba编辑环境里还能看到我的大部分宏,虽然说不能编辑,但能运行,请问如何 隐藏起来。 解答:不用模块函数;重写成类或放到workbook 中;或在程序中直接将菜单宏隐藏。或者:新建 类,然后将模块中的程序拷贝到类,提示:找不到宏。 又问:我现在已经能做到屏蔽调alt+F11键了,虽然不能看到我的宏程序,但是依然可以运行 我的宏,请高手做答,如何隐藏起我的宏。 解答:在宏的声明前加Private。 036。请教多条件求和的问题 大家好,我是个新手,想向大家请教指定多条件求和的函数公式。 CCXXXVI …………………………………………………………Page 237…………………………………………………………… Excel_word_ppt_使用技巧大全(完全版) 譬如,有一张工作表有4列标题:品名,数量,日期,签收人。 若我想求,符合条件为:品名为A ,日期为Y ,签收人为B的数量之和。 该用那个函数公式? 解答:=IF(A2=〃a〃;IF(B2=〃03。10。22〃;COUNTIF(D:D;D2);〃时间无〃);〃无〃) A列品名,B列日期,C列数量,D列签收人用if 嵌套。 或者:数组公式 {=sum((a1:a100=品名)*(c1:c100= 日期)(d1:d100=签收人)*(B1:B100))} 也可以:{=SUM(((A1:A100)=〃a〃)*((B1:B100)=〃03。10。22〃))} 037。请教关于星期的计算? 如何通过输入一个日期:2003…10…20即可得到该天在本年度的第几个星期? 解答:使用 WEEKNUM 函数。 如:=WEEKNUM(A1) =WEEKNUM(TODAY()) 或者:日期在a1 =INT((A1…DATE(YEAR(A1);1;0)+WEEKDAY(DATE(YEAR(A1);1;0);1)+7…WEEKDAY(A1;1))/7) 也可以用VBA : "under the iso standard; a week always begins on a monday; and ends on a sunday。 "the first week of a year is that week which contains the first thursday of the year; "or; equivalently; contains jan…4。 " public function isoweeknum(anydate as date; _ optional whichformat as variant) as integer " " whichformat: missing or 2 then returns week number; " = 2 then yyww " dim thisyear as integer dim previousyearstart as date dim thisyearstart as date dim nextyearstart as date dim yearnum as integer thisyear = year(anydate) thisyearstart = yearstart(thisyear) previousyearstart = yearstart(thisyear 1) nextyearstart = yearstart(thisyear + 1) select case anydate case is 》= nextyearstart isoweeknum = (anydate nextyearstart) 7 + 1 yearnum = year(anydate) + 1 case is 《 thisyearstart isoweeknum = (anydate previousyearstart) 7 + 1 yearnum = year(anydate) 1 CCXXXVII …………………………………………………………Page 238…………………………………………………………… Excel_word_ppt_使用技巧大全(完全版) case else isoweeknum = (anydate thisyearstart) 7 + 1 yearnum = year(anydate) end select if ismissing(whichformat) then exit function end if if whichformat = 2 then isoweeknum = cint(format(right(yearnum; 2); 〃00〃) & _ format(isoweeknum; 〃00〃)) end if end function public function yearstart(whichyear as integer) as date dim weekday as integer dim newyear as date newyear = dateserial(whichyear; 1; 1) weekday = (newyear 2) mod 7 if weekday 《 4 then yearstart = newyear weekday else yearstart = newyear weekday + 7 end if end function 038。请教日期的转换问题 我的程序里有这样一段代码: Dim str As Date str=now Sheet1。Cells(1; 〃A〃) = str 运行后在单元格里显示 2003/11/13 15:19:45 但我想让它显示成如下的格式: 2003年11月13日(小时,分,秒去掉) 我用year (str)想单独取得年的值,但显示1905/06/25 0:00:00 请问有什么好的方法可以实现这种转换吗? 解答: Dim str As Date str=now Sheet1。Cells(1; 〃A〃) = format(str;〃yyyy年mm月dd 日〃) 039。如何用vba实现删除最右边的字符 1月、2月、3月。。。。。。。。。。。10月、11月、12月 CCXXXVIII …………………………………………………………Page 239…………………………………………………………… Excel_word_ppt_使用技巧大全(完全版) 请问如何用vba实现把“月”删除只提取:1、2、3。。。。。。。10、11、12。 解答:Sub abc() Dim a As Integer Dim b As String Dim c As String c = 〃〃 For a = 1 To Len(b) c = c & IIf(Mid(b; a; 1) 〃月〃; Mid(b; a; 1); 〃〃) Next MsgBox c End Sub 或者: