Assigning the value of a worksheet cell to a constant

后端 未结 3 1601
情歌与酒
情歌与酒 2020-12-10 09:24

I am trying to assign the value of a worksheet cell to a constant variable in a VBA macro. The logic behind that action is that the end user is supposed to enter the current

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 09:59

    No it is not possible. As the word suggest it should be Constant.

    Workaround:

    Public Const weekRange As String = "$B$1"
    

    Then in your code:

    Sub Something()
        Dim thisWeek As Integer: thisWeek = Range(weekRange).Value
    '~~> some codes here
    End Sub
    

提交回复
热议问题