Excel VBA Columns如果要使用數字行數,變通方法

Function Columns使用數字()
    '初始值
        Dim Def_Rng As Integer, All_Ball As Integer
        Def_Rng = 6
        All_Ball = 49
    '判斷工作表
        dim Str_ShtName as String
        Str_ShtName="temp"
        call Fn1_新增工作表(Str_ShtName)
    '程式開始
        Dim Str As String
        Dim S1, S2
        With Sheets("temp")
            Str = .Columns(Def_Rng).Address
            S1 = Split(Str, ":")
            Str = .Columns(All_Ball).Address
            S2 = Split(Str, ":")
           
            Str = S1(0) & ":" & S2(0)
        End With
        Debug.Print Columns(Str).Address
End Function

Function Fn1_新增工作表(Str_ShtName)
'當工作表不存在→新增
    Dim ShtName As Object
    On Error GoTo create
        Set ShtName = Sheets(Str_ShtName)
        'ShtName.Cells.Clear
        Fn1_新增工作表 = True
        Exit Function
create:
        Sheets.Add(after:=Sheets(Sheets.Count)).Name = Str_ShtName
End Function

留言

這個網誌中的熱門文章

歐姆龍 HEM-7600T 評價,購買心得分享(打臉文)

超任 三國志3代,登入武將金手指

年青人眼鏡評價(負評),辛酸血淚史分享文