excel - VBA Copy Paste formula search -
code below taken previous question asked
my question - how work if find , search values formulas? ..i've tried changing .value2 doesn't seem work.
with sheets("sheetname") ' change actual sheet name dim r range: set r = .range("c10:g10").find(.range("a10").value2, , , xlwhole) if not r nothing r.offset(4, 0).resize(5).value2 = .range("a14:a18").value2
end with
if you're looking results of formulas, need specify xlvalues
lookin parameter. when it's blank defaults xlformulas
. example, find formula results in "bar" (i.e. =concatenate("b","a","r")
) on sheet "foo", this:
with activeworkbook.sheets("foo") dim r range set r = .usedrange.find("bar", , xlvalues, xlwhole) if not r nothing debug.print r.address end if end
if want find sheet contains actual formula can either leave out lookin parameter entirely or explicitly specify it:
with activeworkbook.sheets("foo") dim r range set r = .usedrange.find("=concatenate(""b"",""a"",""r"")", , _ xlformulas, xlwhole) if not r nothing debug.print r.address end if end
Comments
Post a Comment