0

I'm reading the formula of a cell in excel, the return value is E12*(1-F40 and now I need the result of this fomula how it would be, if I entered it into a cell in my worksheet.

I'm trying to improve a plugin which originally wasn't made by me but I know that it worked, when it simply called Range(returnString) with returnString being E12*(1-F40 or somehow like this, but I cant get it to work. When I call

Range("E12*(1-F40")

I get an error saying

Die Methode "Range" für das Objekt "_Global" ist fehlgeschlagen

a proper translation would be

Method "Range" failed for object "_Global"

or something similar to that.

My first idea was to add = in front and ) at the end of the string to make it a valid formula but that doesnt work neither.

So how can I say excel to calculate a formula like =E12*(1-F40)?

Tom Doodler
  • 1,471
  • 2
  • 15
  • 41

1 Answers1

0

You've got your Excel and your VBA a little tangled up there.

You'd need something like Result = Range("E12").value * (1 - Range("F40").value)

Or you could fill a cell in with the value which would be something like:

Range("A1").value = Range("E12").value * (1 - Range("F40").value)

I hope this helps

Trum
  • 620
  • 3
  • 12
  • Nope, I cant calculate it like that because I dont know how the formula looks like :P But my problem is solved in the comment on my question – Tom Doodler Sep 01 '15 at 08:03