samedi 28 mars 2015

Converting text stored in Excel cell to a formula in VBA

I'm not sure if something like this is possible I've been told by co-workers that it can't because of the nature of strings versus formulas. I would like to take the string:



'"=" & ValRange.offset(0,0).address


With a range declared in my VBA routine and convert is to a formula. In my routine I have the following code:



Sub GetRange()
Dim strSource As String
Dim HomeRange As Range
Dim ValRange As Range

Set ValRange = Range("k1")
Set HomeRange = Range("e6")

strSouce = HomeRange.Value
strSource = Replace(strSource, """", "")
Range("e7") = strSource

End Sub


As you can see I've tried stripping characters but it does not seem to work (I understand as the code currently is that it would strip all quotes but just wanted to use as example. Any thoughts on converting this to a formula is appreciated. Matt


Aucun commentaire:

Enregistrer un commentaire