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 Outputting a formula in a cell using VB

Hi!
I am using VB to maximise a series of functions using the solver Add-In.
Here is a part of my code:

logsum = 0
For l = 1 To n
'Set the initial value of v to 1:
Cells(k + 1, 4) = 1
logsum = logsum + Log(1 + ((Cells(l + 1, 1).Value) ^ 2) / Cells(k + 1,
4).Value)
Next l
loglikelihood = n * Log((1 / (WorksheetFunction.Pi * Cells(k + 1, 4).Value)
^ (1 / 2)) * (Exp(WorksheetFunction.GammaLn((Cells(k + 1, 4).Value + 1) / 2)
- WorksheetFunction.GammaLn(Cells(k + 1, 4).Value / 2)))) - ((Cells(k + 1,
4).Value + 1) / 2) * logsum
Cells(k + 1, 3) = loglikelihood
SolverOk SetCell:="$k+1$3", MaxMinVal:=1, ByChange:="$k+1$4"
SolverAdd CellRef = "$k+1$4", Relation:=3, FormulaText:="0.000001"
SolverSolve UserFinish:=True
Next k

My problem is that I want to maximise the "loglikelihood" with respect
to the value given in cell(k+1,4) but at the moment I am outputting a number
in Cell(k+1,3) not the formula that is used to calculate this number so
Solver does not work. Does anyone have any suggestions how I could output the
formula in the cells instead of the value obtained at the end?

Thanks!


 
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
Outputting comments - Excel 2003 DamianIreland Excel Discussion (Misc queries) 1 October 23rd 09 01:52 PM
Outputting rows with a given value to new worksheet erik_gregory Excel Discussion (Misc queries) 1 January 21st 09 06:24 AM
outputting to multiple worksheets cmumeche Excel Discussion (Misc queries) 0 July 29th 05 08:42 PM
Comparing contents of two spreadsheets and outputting results to a brx Excel Worksheet Functions 5 March 17th 05 01:44 AM
Combining fields and outputting to one cell Doug[_12_] Excel Programming 2 January 6th 05 11:28 PM


All times are GMT +1. The time now is 07:44 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"