关于def 自定义函数的问题
下面是我用excel VBA写的两个代码,请教各位大神,能不能用python写一下,最好能写成def 自定义函数,,imput的内容就做为参数传进去调用也顺便写下,新手见谅!!感谢大神
Sub 时间标尺()
Dim i, j, n
Dim rng As Range
Set rng = Range("B3:C" & Range("c65536").End(xlUp).Row)
x = Application.Min(rng)
y = Application.Max(rng)
Z = InputBox("请输入时间间隔,单位:天", "北仙出品")
Application.DisplayAlerts = False
n = (y - x) \ Z + 1: i = 0
If x > 44310 And y < 45300 Then
Do While x + Z * i <= y
Cells(2, 4 + i) = x + Z * i
i = i + 1
Loop
Else: MsgBox "时间超限,请与作者联系!"
End If
Cells(2, 4 + i) = x + Z * i
Cells(2, 5 + i) = "备注"
rng.NumberFormatLocal = "yyyy-mm-dd"
Range(Cells(2, 4), Cells(2, 4 + i)).NumberFormatLocal = "mm/dd"
Range(Cells(2, 2), Cells(2, 5 + i)).EntireColumn.AutoFit
Range(Cells(1, 2), Cells(1, 5 + i)).Merge
Application.DisplayAlerts = True
End Sub
Sub 留白()
Dim i, j, k
j = InputBox("请输入行高", "北仙出品")
If Len(j) = 0 Or Len(j) = 5 Then
j = 20
End If
For i = Range("a65536").End(xlUp).Row To 3 Step -1
If Cells(i, 1) <> "" Then
Rows(i).RowHeight = j
Rows(i + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows(i + 1).RowHeight = j * 0.4
Rows(i).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows(i).RowHeight = j * 0.4
End If
Next i
End Sub