LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
mb mb is offline
external usenet poster
 
Posts: 10
Default ActiveCell.FormulaR1C1 Sum Function

Seem to be having a problem with this line:

ActiveCell.FormulaR1C1 = "=SUM(rc[4]:rc[adj])"

Object Defined Error (#1004)

The basic premise is there are dates loaded into the 4 row in each of the
columns listed in the array. The Pull_Fwd function is determining if the
date range is less than the number of days entered for the pull forward, and
then only adding those quantities for each item listed (starting at D5).

Entire Script:
Public Sub Pull_Forward()
num = InputBox("Enter the range (in calendar days) you wish to include
in the Pull Forward Calculation: ")
strWeek = Module1.current_date(num)
MsgBox (strWeek)
Call Module1.Pull_Fwd(strWeek)
End Sub

Private Function current_date(num)
today = Date
today = Format(today, "mm/dd")
next_week = DateAdd("d", num, today)
next_week = Format(next_week, "mm/dd")
current_date = next_week
End Function

Private Function Pull_Fwd(strWeek) As Date
Dim adj As Integer
gcolumn = Array("H4", "I4", "J4", "K4", "L4", "M4", "N4", "O4", "P4",
"Q4", "R4", "S4", "T4", "U4", "V4", "W4", "X4", "Y4", "Z4")

count_column = 0
For i = LBound(gcolumn) To UBound(gcolumn)
sheet_date = Range(gcolumn(i)).Text
'MsgBox (sheet_date)
If sheet_date < strWeek Then
count_column = count_column + 1
End If
Next i
count_column = count_column - 1
'MsgBox (count_column)
adj = 4 + count_column
MsgBox (adj)
Range("d5").Select
ActiveCell.FormulaR1C1 = "=SUM(rc[4]:rc[adj])"
End Function

Thanks,
mb


 
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
ActiveCell.FormulaR1C1 Rick Excel Discussion (Misc queries) 3 March 28th 10 10:36 PM
Excel VBA - use of ActiveCell.FormulaR1C1 pgi Excel Programming 1 June 1st 04 08:12 AM
activecell.formular1c1 monika Excel Programming 0 April 29th 04 10:13 AM
Whats wrong with this VBA statement -ActiveCell.FormulaR1C1...? hal Excel Programming 5 November 8th 03 02:48 AM
ActiveCell.FormulaR1C1 Leif Rasmussen Excel Programming 1 October 16th 03 09:46 AM


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