Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

functions vba

ResolvedVersion 2003

William has attended:
Excel VBA Intro Intermediate course
Excel Advanced course

Functions in VBA

Could you please tell me if it is possible to write functions in Visual Basic which then display the formula script in Excel?

I think this would be useful for 2 reasons:

1) The user can see the formula and understand how the values have been calculated by selecting a cell.

2) Cell values will be udpated if the source data changes without having to rerun the function.

Many thanks for your help

RE: Functions in VBA

Hi William

Thanks for your question

You can add a formula programmatically using the formulaR1C1 method of the range object

The following places a sum function that sums a range specified in terms of its relative position to the formula

Worksheets("Sheet1").Range("d10").FormulaR1C1 = "=SUM(R[-12]C[-2]:R[-6]C[-1])"


Regards

Stephen

Thu 5 Nov 2009: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Apply Autosum with keyboard shortcut

If you press Alt and = at the same time, it applies autosum.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.15 secs.