小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Excel列號轉(zhuǎn)換函數(shù)

 JT_man 2011-07-17

以下是兩個使用VBA的自定義函數(shù),用戶轉(zhuǎn)換Excel的列號(2003及其以下版本)

Function ColumnConv(SpecStr As String) As String
    Dim I As Integer, I1 As Integer, I2 As Integer
    If IsNumeric(SpecStr) Then
        '1轉(zhuǎn)A,27轉(zhuǎn)AA
        I = Val(SpecStr)
        If I > 26 Then I1 = Int(I / 26)
        I2 = I Mod 26
        If I2 = 0 Then I2 = 26: I1 = I1 - 1
        ColumnConv = IIf(I1 > 0, Chr(Asc("A") - 1 + I1), "") & Chr((Asc("A") - 1 + I2))
    Else
        'A轉(zhuǎn)1,AA轉(zhuǎn)27
        I = Len(SpecStr)
        If I <> 1 And I <> 2 Then Exit Function
        SpecStr = UCase(SpecStr)
        If I = 1 Then
            I1 = Asc(Mid(SpecStr, 1, 1)) - Asc("A") + 1
        ElseIf I = 2 Then
            I1 = (Asc(Mid(SpecStr, 1, 1)) - Asc("A") + 1) * 26
            I2 = Asc(Mid(SpecStr, 2, 1)) - Asc("A") + 1
        End If
        ColumnConv = I2 + I1
    End If
End Function


下面的
自定義函數(shù)要簡潔多了。


Function ColumnConv1(SpecStr As String) As String
    If IsNumeric(SpecStr) Then
        ColumnConv1 = Left(Cells(1, CInt(SpecStr)).Address(0, 0), Len(Cells(1, CInt(SpecStr)).Address(0, 0)) - 1)
    Else
        ColumnConv1 = Range(SpecStr & 1).Column
    End If
End Function

 '附:取當(dāng)前活動單元格的行號、列標(biāo)
Dim sRow As String, sCol As String
sRow = Split(ActiveCell.Address, "$")(2)
sCol = Split(ActiveCell.Address, "$")(1)
'若活動單元格是D5,則ActiveCell.Address返回"$D$5",Split()函數(shù)將活動單元格地址"$D$5",
'依據(jù)"$"作為分隔符,分割成一個一維數(shù)組,也就是會得到{"","D","5"},
'而這個數(shù)組里有三個元素,分別是(0)、(1)和(2),
'(1)就是取數(shù)組里的第二個元素(列標(biāo)),
'(2)就是取數(shù)組里的第三個元素(行標(biāo))。
 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多