Converting text stored in Excel cell to a formula in VBA -
i'm not sure if possible i've been told co-workers can't because of nature of strings versus formulas. take string:
'"=" & valrange.offset(0,0).address
with range declared in vba routine , convert formula. in routine have following code:
sub getrange() dim strsource string dim homerange range dim valrange range set valrange = range("k1") set homerange = range("e6") strsouce = homerange.value strsource = replace(strsource, """", "") range("e7") = strsource end sub
as can see i've tried stripping characters not seem work (i understand code strip quotes wanted use example. thoughts on converting formula appreciated. matt
let's valrange defined cell a1. in cell a2, have row offset value (say 0), , in cell a3 have column offset value (say 2). in cell a4, enter =address(row(offset(a1,a2,a3)), column(offset(a1,a2,a3)))
you'll $c$1 in cell a4 value.
so, 2 offsets give cell appropriate offset want. take row, , column of cell , send address function address.
to convert address value in offset cell, use =indirect(a4)
. give value of whatever in cell c1.
of course, can take these functions , call them vb code if you'd prefer.
Comments
Post a Comment