标题:关于def 自定义函数的问题
取消只看楼主
螭蛊
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2023-2-24
结帖率:75%
已结贴  问题点数:10 回复次数:1 
关于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
搜索更多相关主题的帖子: Application End Rows If def 
2023-03-05 17:34
螭蛊
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2023-2-24
得分:0 
回复 2楼 sheeboard




把原始状态和成图发你看一下就明白了,多刷新几次,这个网站总有打不开的时候
2023-03-06 16:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-511453-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.101300 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved