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: 144
Default Adding formulas to cells

I am trying to add the following formual to a column of cells in Excel. The
code first goes through and counts the number of rows and then adds the
formula. We have used this many time before but are unable to get this one
to work. I have narrowed it down to it not working on the ones that use "*"
and/or "/" in them. Can anyone help me with this?

I posted this Friday and didnt get a response, so I am trying to clarifiy
and simplify my question. Any and all help will be greatly appriciated.

One that does work:

Call InsertFormula(GetRowCount("C"), 15,
"=IF(ISERROR(FIND(""$"",S#,1))=TRUE,P#,"""")")

One that does not work:

Call InsertFormula(GetRowCount("C"), 20,
"=IF(AB#=""1"",S#,IF(AB#=""3"",N#/W#/100,""""))=SUM(T#*V#))")

This is some of the code we use before using the lines above:

Private Function GetRowCount(strColumn As String) As Integer
Dim iCount As Long
Dim i As Long

For i = 1 To 65000
If Range(strColumn & i).Value < "" Then
iCount = iCount + 1
Else
Exit For
End If
Next
GetRowCount = iCount
End Function

Private Sub InsertFormula(intRowCount As Long, intColumn As Long, strFormula
As String)
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet

For i = 2 To intRowCount
ws.Cells(i, intColumn) = Replace(strFormula, "#", CStr(i))
Next
End Sub



 
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
Adding cells with formulas Amy Excel Worksheet Functions 2 November 10th 09 05:14 PM
Adding formulas Steved Excel Worksheet Functions 4 April 11th 07 06:10 PM
adding formulas to blank cells jerrystan Excel Programming 4 November 4th 05 11:19 PM
Adding cells that already have formulas critter Excel Discussion (Misc queries) 2 September 28th 05 06:46 AM
adding cells that contain formulas that have returned error messag Daniel R Excel Worksheet Functions 3 February 21st 05 07:14 PM


All times are GMT +1. The time now is 12:27 PM.

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"