Excel 2007
我需要将一个值放入调用者行的已知列...
Function ProjectDaysThisMonth(theDate As Date) As Double
Dim d1 As Date
Dim d2 As Date
Dim rngCaller As Range
' start and end of month
d1 = theDate - Day(theDate) + 1
d2 = Application.EoMonth(d1, 0)
' where-ever this function was called from the sheet
Set rngCaller = Application.Caller
...
' workdays_thismonth was set to the # of days of month from where this function was called on the sheet
' remaining_days was set to previous months work and work done this month
' now once you're in a certain certain scenario
' put the finish date into a known column for this row:
Worksheets("Plan").Cells(rngCaller.Row, 4).value = DateAdd("d", workdays_thismonth + remaining_days, d1)
' above, she blows up good... no worky
...
End Function
当我尝试设置另一个单元格的值时,它就会崩溃。 我应该使用评估功能吗? 有点像...
rngCaller.Parent.Evaluate "setValue(" & rngCaller.Address(False, False) & "," & newDateValue & ")"
或者有更清洁的方式吗?