VBA: 带参数带返回值的函数

Function pda(x)
a = x
If Len(a) = 1 Then
 ab = "00" & a
ElseIf Len(a) = 2 Then
  ab = "0" & a
ElseIf Len(a) = 3 Then
  ab = a
 
End If
 pda = ab
End Function
Sub pd()
n = Worksheets.Count

Rem ¼ÆË㵱ǰËùÓй¤×÷±íÊýÁ¿
Rem xxΪÿ¸ö¿¼³¡µÄÈËÊý
Rem yyΪµ±Ç°×¨Òµ±ê¼Ç
Rem mmΪµ±Ç°×¨Òµ¿¼ÉúÈËÊý
Rem shuΪµ±Ç°×¨Òµ¿¼ºÅÕÅÊý
Rem shuuΪµ±Ç°×¨Òµ¿¼³¡ÊýÁ¿
xx = 44
yy = 2001
mm = 999

If Int(mm / xx) = mm / xx Then
shuu = mm / xx
ElseIf Int(mm / xx) <> mm / xx Then
shuu = Int(mm / xx) + 1
End If
If Int(mm / 30) = mm / 30 Then
shu = mm / 30
ElseIf Int(mm / 30) <> mm / 30 Then
shu = Int(mm / 30) + 1
End If

bz = 0
For i = 1 To shuu
ab = pda((i - 1) * i)
ab1 = pda((i * xx))
  
Rows("1:1").RowHeight = 171.75
Rows("2:2").RowHeight = 123.75
Columns("A:A").ColumnWidth = 130.5
Range("A1:c10").Font.Name = "ËÎÌå"
Range("A1:c10").Font.Bold = True
Range("A1:A1").Font.Size = 90
Range("A2:A2").Font.Size = 60
Range("A1:a2").HorizontalAlignment = xlCenter
Range("a" & 1) = "¼ÆËã»ú¿¼³¡1"
abb = ab
Range("a" & 2) = "¿¼ºÅ£¨2003" & ab & "-2003" & (ab1) & ")"

Next
End Sub

 

上一篇:Excel Micro (VBA)


下一篇:Excel-VBA学习笔记