Function Question
I wouldn't hardcode the FuelRateMonthly or TrackingInfo details, you should
have UDF arguments for these, and pass them ehwn calling.
FuelUsage is never defined or set in the code.
I don't kknow what you are trying to do here
Mobe = TrackingInfo.Range.Offset(ProperRow, 3).Value
as TrackingInfo is just a value so you can't offset it. Perhaps if you pass
TrackingInfo as a range argument, you could then use
Mobe = TrackingInfo.Offset(ProperRow, 3).Value
etc.
RP
(remove nothere from the email address if mailing direct)
"Egon" wrote in message
oups.com...
Below you will see the entire fuction, I have the beginning and ending
pieces working, however the middle is not doing very well. Thanks for
the RowOffset Piece, that worked great Bob, but my problem is that its
not acting as I would expect. The Comments will tell you what I'm
expecting it to do. Maybe someone can lend a hand and tell me how to
fix it and what I've done wrong.
TIA
J.
Function DailyCost(TrackDate)
Celladdress = Application.ThisCell.Address
ProperRow = Application.Caller.Row - TrackDate.Row
'Works To here
'Pull the Rate for Fuel from the Cell H7 on the same sheet as the
Function
FuelRateMonthly = ActiveSheet.Range("H7")
'Set the location of the information where the values will be pulled
from
TrackingInfo = Worksheets("Project Summary").Range("G9")
'Calculate the fuel usage for the day based on the amount used
*rate*conversion
FuelRate = WorksheetFunction.Sum(FuelRateMonthly * FuelUsage * 264.15)
'Set StartDate equal to the cell G9 on the 'Project Summary' Sheet
using a Relative Reference
StartDate = TrackingInfo.Range.Offset(ProperRow, 0).Value
'Set EndDate equal to the cell H9 on the 'Project Summary' Sheet using
a Relative Reference
EndDate = TrackingInfo.Range.Offset(ProperRow, 1).Value
'Set TrackingRate equal to the cell I9 on the 'Project Summary' Sheet
using a Relative Reference
TrackingRate = TrackingInfo.Range.Offset(ProperRow, 2).Value
'Set DailyRate to the FuelRate + TrackingRate
DailyRate = WorksheetFunction.Sum(FuelRate, TrackingRate)
'Set Mobe equal to the cell J9 on the 'Project Summary' Sheet using a
Relative Reference
Mobe = TrackingInfo.Range.Offset(ProperRow, 3).Value
'Set MobeDate equal to the cell K9 on the 'Project Summary' Sheet using
a Relative Reference
ModeDate = TrackingInfo.Range.Offset(ProperRow, 4).Value
'Set DemobeDate equal to the cell M9 on the 'Project Summary' Sheet
using a Relative Reference
DeMobeDate = TrackingInfo.Range.Offset(ProperRow, 6).Value
'Set DeMobe equal to the cell L9 on the 'Project Summary' Sheet using a
Relative Reference
DeMobe = TrackingInfo.Range.Offset(ProperRow, 5).Value
'This Section Works
EndDateNull = IIf(EndDate = "", DailyRate, 0)
TrackEnd = IIf(TrackDate <= EndDate, DailyRate, EndDateNull)
TrackToday = IIf(TrackDate = StartDate, TrackEnd, 0)
StartTracking = IIf(Now = TrackDate, TrackToday, 0)
DailyCost = StartTracking
|