说起来不怕大家笑话,在it圈子混了这这么久了还不会使用exel 呢赫赫。老板让作exel的vba程序更是什么也不会了。连怎么启动vba编辑器都不知道呀!我写了个c#的计算器。老板不高兴!!!必须用exel!算了吧,不学不知道啊!!!老子这么说的赫赫。干这行的哪能怕接触新事物!!!来吧谁怕谁阿!!!作exel的vba操作其实关键就是找到相应的cell单元格。剩下的就随心所欲了。有点基础的就没什么难度了。
Function myfun(forwarder As Range, region As Range, weight As Range)
'
mycol = forwarder.Column
myrow = forwarder.Row
temp = Worksheets(2).Cells(myrow, mycol).Value


mycol2 = region.Column
myrow2 = region.Row
temp2 = Worksheets(2).Cells(myrow2, mycol2).Value


mycol3 = weight.Column
myrow3 = weight.Row
temp3 = Worksheets(2).Cells(myrow3, mycol3).Value


For Each c In Worksheets(1).Range("A1:C5")
    If c.Value = temp Then
        If Worksheets(1).Cells(c.Row, 2).Value = temp2 Then
        myfun = Worksheets(1).Cells(c.Row, 3).Value * temp3
        Exit For
        End If
           
    End If
Next
i = i + 1


对了还有我记得在(office)2k上运行function (usrdefine)的时候可以没有什么问题,在2k3上就出现找不到参数。原来很简单就是宏使用的安全性问题。该城low就万事ok。

posted on 2005-09-12 11:01  Mint  阅读(1086)  评论(4编辑  收藏  举报