VBA Finding the next column based on an input value

后端 未结 5 1517
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 21:56

In a program that I\'m trying to write now I take two columns of numbers and perform calculations on them. I don\'t know where these two columns are located until the user tell

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-27 22:29

    There are a few syntactical problems with @rskar's answer. However, it was helpful in producing a function that grabs a column "letter", based on an input column "letter" and a desired offset to the right:

    Public Function GetNextCol(TheCol As String, OffsetRight As Integer) As String
        Dim TempCol1 As String
        Dim TempCol2 As String
        TempCol1 = Range(TheCol & "1").Address
        TempCol2 = Range(TempCol1).Offset(0, OffsetRight).Address(0, 0, xlA1)
        GetNextCol = Left(TempCol2, Len(TempCol2) - 1)
    End Function
    

提交回复
热议问题