VBA formulas with @

Asked

Viewed 41 times

1

When you write the formula of a function by VBA, and add some excel formula, it increments a @ before the formula automatically. For example:

Selection = "=SOMA(A1)"

In the spreadsheet formula bar it is =@SOMA(A1) and does not run. Does anyone know how to get this automatic@ out? Thanks.

1 answer

0

Selection is a generic object that can have several types. In your case it is a Range, representing a cell. To set formulas using Selection, do:

Selection.FormulaLocal = "=SOMA(A1)"

Formulalocal is used to transform Soma (Portuguese) into Sum (English) To see what Selection represents, type in Immediate Verification (Ctrl+G in VBA):

?Typename(Selection)

This will return what Selection is at that time. To learn more about that object, in your case Range, Press F2 and search for Range. There you will have a lot of information.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.