Re: Simple Multiplication Formula

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Fantastic!!!
Thank you so much for that prompt reply
That works beautifully!

It produces an "absolute" reference
example:
=$C$21*$D$21
which is fine for my current application....

just for my education, how would I change it to produce a "relative"
reference
=C21*D21
?

also is there a place in excel help where I should have been able to find
this?
or other good links for programatic object model info

Thanks again for the solution
Mark
:-)


"ilia" <iasafiev@xxxxxxxxx> wrote in message
news:9f7e2b35-84f7-4e95-8c53-547b3e0e1991@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You want it to be like this, perhaps?

Public Function MultiplyCells(RowIdx As Long, _
ColOne As Long, _
ColTwo As Long, _
ResultCol As Long, _
oWs As Worksheet) As Boolean
With oWs
.Cells(RowIdx, ResultCol).Formula = "=" & _
.Cells(RowIdx, ColOne).Address & "*" & _
.Cells(RowIdx, ColTwo).Address
End With
End Function


On Dec 19, 1:50 pm, "MP" <NoS...@xxxxxxxxxx> wrote:
I've been searching google for some time now and cant' find the answer
This is probably too simple a question

I'm trying to write a function that will put a formula in ResultCol to
multiply InputColOne times InputColTwo

Public Function MultiplyCells(RowIdx As Long, ColOne As Long, ColTwo As
Long, ResultCol As Long, oWs As Worksheet) As Boolean
oWs.Cells(RowIdx, ResultCol).FormulaR1C1 = oWs.Cells(RowIdx,
ColOne).Value
* oWs.Cells(RowIdx, ColTwo).Value
End Function

I'm sure my syntax is wrong, I don't clearly understand the .FormumaR1C1
method...
It's not throwing an error, but it's putting the value in the result
cell,
not the formula

any hints?
Thanks Mark



.



Relevant Pages

  • Re: Simple Multiplication Formula
    ... oWs As Worksheet) As Boolean ... I'm trying to write a function that will put a formula in ResultCol to ... Public Function MultiplyCells(RowIdx As Long, ColOne As Long, ColTwo As ...
    (microsoft.public.excel.programming)
  • Re: Simple Multiplication Formula
    ... Public Function MultiplyCells(RowIdx As Long, ... ColOne As Long, _ ... ResultCol As Long, _ ... oWs As Worksheet) As Boolean ...
    (microsoft.public.excel.programming)
  • Re: Writing Access functions
    ... passing values by Value or by Reference. ... Public Function NameFromIDAs String ... If you pass a control reference: ...
    (microsoft.public.access.modulesdaovba)
  • Re: Dynamically load functions
    ... $includeMap should contain 1 entry for each function I wish to reference, ... Is the function 'call_user_func_array' the actual system function calling routine? ... public function __call{ ...
    (comp.lang.php)
  • Re: Function Warning - Null Reference
    ... Warning 1 Function 'Dec2hms' doesn't return a value on all code paths. ... null reference exception could occur at run time when the result is used. ... Public Function Dec2hmsAs String ... Public Function Dec2hms As String ...
    (microsoft.public.dotnet.languages.vb)