Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Help with Coding a Formula Please


Hi. Glad it's working. Just throwing out an idea here. Earlier you
mentioned that...
I am Finding this Difficult Because of the
Relative and Absolute References etc.


Would working with Range Names help?
Also, it looks to me that the only errors would be if B28 were 0 (divide by
0) or an invalid Combin( ).
As an idea, perhaps only test for these two.
Again, just throwing out some ideas... :)

Sub TestMe()
Dim TotalRows As Long
Const Fx As String = _
"=IF(ISERROR((1/Y)+COMBIN(m,n)),"""",(1-X/Y)^(m-n)*(X/Y)^n*COMBIN(m,n))"

TotalRows = [B29]
If Not WorksheetFunction.IsNumber(TotalRows) Then
MsgBox "Put a number in B29!"
Exit Sub
End If

ActiveWorkbook.Names.Add "X", [B27]
ActiveWorkbook.Names.Add "Y", [B28]
ActiveWorkbook.Names.Add "n", [C30:J30]
ActiveWorkbook.Names.Add "m", [B31].Resize(TotalRows)

Rows("31:65536").ClearContents
With [B31]
.Value = 1
.AutoFill .Resize(TotalRows), xlFillSeries
End With

With [C31].Resize(TotalRows, 8)
.Formula = Fx
.NumberFormat = "0.00%"
End With
End Sub


--
Dana DeLouis
Win XP & Office 2003


"Paul Black" wrote in message
oups.com...
Hi Dave,

Splendid.
Thank you VERY Much for your Time, Effort & Help. It is Most
Appreciated.

All the Best.
Paul



Dave Peterson wrote:
It sounds like you can delete all the rows in 31:65536???

If yes, then (within the with/end with structure):

.rows("31:65536").clear
or
.rows("31:65536").clearcontents
or
.rows("31:65536").delete

(maybe???)




Paul Black wrote:

Hi Dave,

Thanks VERY Much for the Update and Detailed Description.
One Final Request Please.
Because the Value in Cell "B29" can be Less Or More Each Time it is
Run, I would like it to Delete the Rows that were Used Previously
Before Producing the New Data.
I have Tried the Following But Without Any Success.

Range("B31", Range("J:").End(xlDown).Offset(-1, 0)).EntireRow.Delete

Range("B31", Range("J:").End(xlDown)).EntireRow.Delete

Range("B31:J").Select
Selection.Delete Shift:=xlUp

Range("B31:J").End(xlDown).Select
Selection.Delete Shift:=xlUp

Here is the Code I am Currently Using :-

Option Explicit
Sub testme()

Dim myFormula As String
Dim FirstCell As Range
Dim FirstRow As Long
Dim TotalRows As Variant

myFormula _
= "=IF(ISERROR((1-$B$27/$B$28)^($B31-C$30)*($B$27/$B$28)^C$30*" &
_

"COMBIN($B31,C$30)),"""",(1-$B$27/$B$28)^($B31-C$30)*($B$27/$B$28)^C$30*"
& _
"COMBIN($B31,C$30))"

With ActiveSheet
Set FirstCell = .Range("c31")
FirstRow = FirstCell.Row
TotalRows = .Range("b29").Value
If Application.IsNumber(TotalRows) = False Then
MsgBox "Put a number in B29!"
Exit Sub
End If

With FirstCell.Resize(TotalRows, 8) 'C:J is 8 columns.
.Formula = myFormula
.NumberFormat = "0.00%"
End With

With FirstCell.Offset(0, -1).Resize(TotalRows, 1)
.Formula = "=row()-" & FirstRow - 1
.Value = .Value
End With

End With

End Sub

Most Appreciated.
Thanks in Advance.
All the Best.
Paul


--

Dave Peterson




Reply
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
converting question; function, formula, or coding? gtrask Excel Worksheet Functions 4 July 8th 08 12:25 AM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Formula Color Coding Andrew Excel Discussion (Misc queries) 5 March 25th 05 08:41 PM
vba coding for formula in cell RDP1 Excel Programming 2 February 7th 05 10:05 PM
Coding help fpd833 Excel Programming 2 November 12th 04 08:22 PM


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