How to convert a String to a Range Object

后端 未结 6 1506
名媛妹妹
名媛妹妹 2021-01-23 22:44

Is there anyway to convert a string value to a Range object ? I\'m having a function which takes a Range object as a argument and need to pass a single string parameter to it

6条回答
  •  执笔经年
    2021-01-23 23:15

    Here is my solution that involves no need for a new function.

    1.Make dynamic string variable first

    2.Then finalize it by creating a range object out of this string via a range method: Set dynamicrange= range (dynamicstring)

    You can manipulate dynamicstring as you want to, I just kept it simple so that you can see that you can make range out of a string variable.


    Sub test()
    
    Dim dynamicrangecopystring As String
    Dim dynamicrangecopy As range
    dynamicrangecopystring = "B12:Q12"
    Set dynamicrangecopy = range(dynamicrangecopystring)
    
    End Sub
    

提交回复
热议问题