View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Method Range of Object Global Failed


Two corrections...
1...
Dim workbook_name As String
workbook_name = "HistoryDialog.Active_Workbook1"
2...
Range("AM" & rwindex).Formula = "=SUM(AM2:AM" & rwindex - 1 & ")"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Pam"
wrote in message
Hello:
I am trying to put in a formula based on when a particular cell is
empty, but
I get Method Range of Object Failed. When debugging I get the row
number but it does not work foir me.
Here is a snippet of my code

If Cells(rwindex, X) = "" Then
Add_Sum (rwindex)
End If

'In the above logic if the rwindex is empty I will call the
Add_Sum(rwindex)
and pass in the rwindex that is empty.
Then I want to add a sum to a particular column on that row

Public Function Add_Sum(rwindex)
Dim Ac As String
Ac = "3G_Triage_Analysis"
workbook_name = HistoryDialog.Active_Workbook1
Windows(workbook_name).Activate

Sheets(Ac).Select
Range("AM " & rwindex & " ").Formula = "=SUM(AM2:AM & rwindex)"

'I will be doing this for columns AM2 to BJ2. I want to sum up
numbers in the column lets say from AM2 until there is no ID in
rwindex which is column A.
So rwindex will be the number row were I want the formula to do the
Sum
Is this legal, I can't think of any other way to get the value out of
rwindex.
End Function

I appreciate your help
Pam