LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Help with cell references dependent on strings

Hi!
I'm trying to output formulas onto my worksheet but my cell references are
dependent on the strings that I am using. I have used the following method to
try and get over this problem, as suggested to me previously (thanks!):
Code:
'Calculate the log term for each random number
Const Formula As String = "=ln(1+AX^2/$D$2)"
For i = 1 To n
Cells(i + 1, 2) = Replace(Formula, "X", i + 1)
Next i
'Sum this column
Cells(n + 2, 2).FormulaR1C1 = "=Sum(R2C:R[-1]C)"
'Calculate loglikelihood and output onto the sheet
Const loglikelihood As String = "=Y-2* ln((1 / Sqrt(Pi() * $D$2)) *
(exp(GammaLn(($D$2 + 1) / 2) - GammaLn($D$2 / 2))) - (($D$2 + 1) / 2) * $B$Y"
Cells(2, 3) = Replace(loglikelihood, "Y", n + 2)

The first part works and the summation but I get an error message (run-time
error '1004': Application defined or object-defined error) when I try to
calculate and output the loglikelihood in a similar method. I need the 'Y+2'
part to be n and the cell reference at the end of the formula to be $B$n for
an n inputted by the user. Any ideas where I am going wrong or another way I
can do this?
Thanks!
Lisa

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
convert relative cell references to absolute cell references via amacro? Dave F[_2_] Excel Discussion (Misc queries) 1 May 15th 08 04:43 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Furmula Dependent Cell References ned Excel Discussion (Misc queries) 2 May 4th 06 05:03 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM


All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"