以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  半Excel与VBA中使用Excel函数的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=22518)

--  作者:yankunhao
--  发布时间:2012/8/15 15:14:00
--  半Excel与VBA中使用Excel函数的问题

如有下面的代码,请问其中的"a = App.WorksheetFunction.RoundUp(Len(ws.range(s1)), 0)
"

有什么问题吗?

该语句主要是想计算Exce单元格中的字数的,但在说明文件中找不到用VBA如何调用Excel函数的相关内容.

 

 

Dim Book As New XLS.Book(ProjectPath & "Attachments\\销售订单.xls")
Book.Build()
Dim s As String = Tables("osal_ord1").Current("sheet_no")
s = s.Replace("/"," ")
Book.Save(ProjectPath & "Reports\\销售订单\\" & s & ".xls")
Dim App As New MSExcel.Application
App.Visible = True
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(ProjectPath & "Reports\\销售订单\\" & s & ".xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim range As MSExcel.Range

Dim lastrow As Long
Dim rng As Integer
lastrow = Ws.usedrange.rows.count-13

rng = ws.range(Ws.cells(11,1),Ws.cells(lastrow,1)).entirerow.autofit
Dim r As Long
r =lastrow-11
Dim s1 As String = "B" & r
Dim a As Integer

a = App.WorksheetFunction.RoundUp(Len(ws.range(s1)), 0)
If a > 0 Then
ws.range(s1).RowHeight = 409
End If
Wb.Save