View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
Default VBA code needed to apply formula to each value in a dynamic range!

Sub CreateFormula()
Dim CopyRange As Range
Set CopyRange = Range("B2", Range("B2").End(xlDown))
Sheets("Sheet2").Range(CopyRange.Address).FormulaR 1C1 = _
"=(-1/2)*LN(1-Sheet1!RC)"
End Sub

HTH

Die_Another_Day

Post back if you need help applying the code
burk wrote:
Hi to all VBA experts!

Unfortunately, I am an entire Novice to VBA, and I am faced with the
following task:

In Sheet1 I have an array of numbers between 0 & 1; The problem is that
this array is of -varying -size (extending from B2 over a varying # of
rows & columns)...and I want to apply the following formula to each
value in this array: (-1/2)*LN(1-ValueFromSheet1)

The corresponding output shall be displayed in the subsequent Sheet2
(from B2 onwards); logically, the output will be another array of the
same size as the one in Sheet1 (since for each value in Sheet1 I will
have an output value in Sheet2)

Ideally, the output array will be displayed in the same cells as the
input array, i.e. starting from B2 & cover the same rows & columns in
Sheet2
Sheet2


Any ideas of how to go about it are very much appreciated!!


--
burk
------------------------------------------------------------------------
burk's Profile: http://www.excelforum.com/member.php...o&userid=36955
View this thread: http://www.excelforum.com/showthread...hreadid=567287