How to pass variable string as an argument to Names Object

63 views Asked by At

I'm using a code to identify a the name of a range and store it in a variable. Then, pass this variable using Names object to a Range variable to convert the string to a cell range. However, I'm getting Application defined or Object Defined error. What would be the correct way to do this?

    Dim Temp As String, Temp1 As String, Temp3 As String
    Dim Temp2 As Range
    Temp = "abcd"
    Temp1 = "xyz"
    Temp3 = Temp1 & Temp
    Set Temp2 = ActiveWorkbook.Names(Temp3).RefersToRange

I would want Temp2 to have a range value of A1:B5 corresponding to the named range xyzabcd

0

There are 0 answers