Office中国论坛/Access中国论坛

标题: 问一个公式中带标注的问题! [打印本页]

作者: LIXIANACCP    时间: 2006-2-6 17:43
标题: 问一个公式中带标注的问题!
例如,在A1单元格中输入  2[长]*3[宽]*2[厚]*2个+2[长]*1[宽]*2[厚]*2个

在B1单元格中显示上述得数:32  (能显示<SUB>32M3就更好!!!)</SUB>
作者: wang1950317    时间: 2006-2-7 17:47
本栏有位专家给出一个自定义函数flw2,(你可以搜索一下),在模块中添加如下代码:

Function FLW2(X As Range, Y As Integer)
If Y = 1 Then
  For I = 1 To Len(X)

     If Val(Mid(X, I, 1)) > 0 Or Mid(X, I, 1) = "0" Or Mid(X, I, 1) = "+" Or Mid(X, I, 1) = "-" Or Mid(X, I, 1) = "*" Or Mid(X, I, 1) = "/" Or Mid(X, I, 1) = "^" Or Mid(X, I, 1) = "mod" Or Mid(X, I, 1) = "." Or Mid(X, I, 1) = "(" Or Mid(X, I, 1) = ")" Then
      Q = Q & Mid(X, I, 1)
     End If
     FLW2 = Application.Evaluate(Q)
  Next I
ElseIf Y = 2 Then


  For M = 1 To Len(X)

         A = Application.WorksheetFunction.Substitute(X.Value, 0, "")
         B = Application.WorksheetFunction.Substitute(A, 1, "")
         C = Application.WorksheetFunction.Substitute(B, 2, "")
         D = Application.WorksheetFunction.Substitute(C, 3, "")
         E = Application.WorksheetFunction.Substitute(D, 4, "")
         F = Application.WorksheetFunction.Substitute(E, 5, "")
         G = Application.WorksheetFunction.Substitute(F, 6, "")
         H = Application.WorksheetFunction.Substitute(G, 7, "")
         I = Application.WorksheetFunction.Substitute(H, 8, "")
         J = Application.WorksheetFunction.Substitute(I, 9, "")
Next M
  
  
  FLW2 = J

End If

End Function

在B1中调用这个函数即可。


作者: LIXIANACCP    时间: 2006-2-15 01:16
以下是引用wang1950317在2006-2-7 9:47:00的发言:


本栏有位专家给出一个自定义函数flw2,(你可以搜索一下),在模块中添加如下代码:

Function FLW2(X As Range, Y As Integer)
If Y = 1 Then
  For I = 1 To Len(X)

     If Val(Mid(X, I, 1)) > 0 Or Mid(X, I, 1) = "0" Or Mid(X, I, 1) = "+" Or Mid(X, I, 1) = "-" Or Mid(X, I, 1) = "*" Or Mid(X, I, 1) = "/" Or Mid(X, I, 1) = "^" Or Mid(X, I, 1) = "mod" Or Mid(X, I, 1) = "." Or Mid(X, I, 1) = "(" Or Mid(X, I, 1) = ")" Then
      Q = Q & Mid(X, I, 1)
     End If
     FLW2 = Application.Evaluate(Q)
  Next I
ElseIf Y = 2 Then


  For M = 1 To Len(X)

         A = Application.WorksheetFunction.Substitute(X.Value, 0, "")
         B = Application.WorksheetFunction.Substitute(A, 1, "")
         C = Application.WorksheetFunction.Substitute(B, 2, "")
         D = Application.WorksheetFunction.Substitute(C, 3, "")
         E = Application.WorksheetFunction.Substitute(D, 4, "")
         F = Application.WorksheetFunction.Substitute(E, 5, "")
         G = Application.WorksheetFunction.Substitute(F, 6, "")
         H = Application.WorksheetFunction.Substitute(G, 7, "")
         I = Application.WorksheetFunction.Substitute(H, 8, "")
         J = Application.WorksheetFunction.Substitute(I, 9, "")
Next M
  
  
  FLW2 = J

End If

End Function

在B1中调用这个函数即可。

我觉得头晕得很!!!!!!!!!!!!!1[em06][em06]
作者: wang1950317    时间: 2006-2-17 22:40
不复杂,在Excel页面,选[工具]/[宏]/VB编制器   在显示的页面中选工具栏[插入]/[模块],你把这段代码复制过去就大功告成了。使用时和使用其他函数一样。在B1中输入  =FLW2(A1,1)。
作者: scottwang    时间: 2006-2-18 18:59
定义名称Z=EVALUATE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Sheet1!A65534,"[长]",""),"[宽]",""),"[厚]",""),"个",""))

在B1中输入=Z
作者: ahng    时间: 2006-2-22 18:21
复杂。
作者: fyxhh    时间: 2006-5-15 03:28
我试了一下,可用,但当“[]”内出现数字时就不能用了如:公式“23[1轴]+24[2轴]”显示的结果是“472”非“47”这是什么原因,能改正使“[]”内的数公作为标注吗?


作者: 蓝天之下    时间: 2006-5-15 06:26
看不懂啊~唉~




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3