0

If i enter the following excel function in a cell and press enter, it works:

"=T_DisplayReport(A1)"

but if I write the following in VBA:

Sheets("Sheet1").Cells(1, 1).Formula = "=T_LoadReport(""X"",""Y"",true)"
Sheets("Sheet1").Cells(1, 1).Calculate

Sheets("Sheet1").Cells(2, 1).Formula = "=T_DisplayReport(A1)"
Sheets("Sheet1").Cells(2, 1).Calculate    

it doesnt work. How can I hardcode the cell A1 into the above VBA so that it is recognised and the function works?

EDIT: A1 contains another function which fetches data and saves it to the local cache. T_DisplayReport() grabs cell A1 to then display this data.

13
  • Hmmm, I just tested it and it works... Can you show us what the function does? Commented Jul 2, 2012 at 16:10
  • I cant really show, as its a custom addin function, but basically i have one function which goes and gets a load of data and puts it into the local cache. This second function then retrieves the data from the local cache and pastes it onto the sheet. I didnt write these so cant really offer code. Commented Jul 2, 2012 at 16:13
  • Hmmm... Can you test this for me... What does this give you? MsgBox Application.Evaluate("=DisplayReport(A1)") Commented Jul 2, 2012 at 16:15
  • I had to remove the MsgBox bit, but it still didnt evaluate cell A1 Commented Jul 2, 2012 at 16:18
  • 1
    If =T_DisplayReport(A1) works in the Excel cell and MsgBox Application.Evaluate("=T_DisplayReport(A1)") doesn't then there is not much I can suggest without seeing the function... Commented Jul 2, 2012 at 16:34

1 Answer 1

1

Depending on which version of Excel you are using, your Range.Calculate statements may not correctly handle asynchronous function dependencies.
Try removing your first Range.Calculate and replace your last range.calculate with Sheets("Sheet1").Calculate or Application.Calculate

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.