Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Place this in a standard module function AddUp(rng as range, rng2 as range) as variant on error goto haveError AddUp=rng.value + rng2.value exit function haveError: AddUp="Error!" end function In A1 on a worksheet in the same workbook enter =AddUp(B1,C1) Tim. "Snowsride" wrote in message ... When I use an Excel function I type =FunctionName( I then move the active cell to the one on which I want to perform the calculation and then type ) and hit enter. I want to create a custom function but can't figure out how to include a reference to the cell on which the formula is to be performed. I've recorded a macro using a built in Excel function thus: Cell D2 is the active cell and I enter the formula =Weeknum(a2) which Excel records as ActiveCell.FormulaR1C1 = "=WEEKNUM(RC[-3])" But this will only work if the cell to be referenced is 3 colums to the left of the cell that holds the formula. I want to use the function in any cell and perform it's calculation on any other cell i.e. I wnat to use my function like any other Excel function. How can I do this please? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I refer to the results of a function in a cell not the form | Excel Worksheet Functions | |||
How to refer to a text piece in a VBA custom function? | Excel Discussion (Misc queries) | |||
In VBA, How to Refer to Cell In Specific Column But Selected Rows? | Excel Discussion (Misc queries) | |||
referencing active cell works in a sub but not in a custom function | Excel Worksheet Functions | |||
Refer to the cell in which a function is entered. | Excel Programming |