Hi All,
Thanks for having me on this forum, and pardon my grammar too. I have daily sale spreadsheet that I would like to auto populate cells with user defined vba functions that takes in the daily egg laying from a user and calculates the number of creates and then calculate the daily sales. This is for the month, thus from 1st to 31st depends which month we're dealing with. The problem I have is getting the crates for the day is easy (.e.i. crates = Quotient(eggs,30)), but this will have a remainder of (Eggs = egg - 30*Quotient(eggs,30)) and where (Sale = crates*rate). I would like to be able to add whatever that got remained from yesterday to todays numbers and repeated the process again till the end of the month. The other thing is the beginning of the month starts a new row which I cannot or perhaps not sure how I can access. I have written some functions which doesn't seem to be working. I will gladly appreciate your help on this, also please find attached image for your reference that may be helpful.
Thanks for having me on this forum, and pardon my grammar too. I have daily sale spreadsheet that I would like to auto populate cells with user defined vba functions that takes in the daily egg laying from a user and calculates the number of creates and then calculate the daily sales. This is for the month, thus from 1st to 31st depends which month we're dealing with. The problem I have is getting the crates for the day is easy (.e.i. crates = Quotient(eggs,30)), but this will have a remainder of (Eggs = egg - 30*Quotient(eggs,30)) and where (Sale = crates*rate). I would like to be able to add whatever that got remained from yesterday to todays numbers and repeated the process again till the end of the month. The other thing is the beginning of the month starts a new row which I cannot or perhaps not sure how I can access. I have written some functions which doesn't seem to be working. I will gladly appreciate your help on this, also please find attached image for your reference that may be helpful.
VBA Code:
Public Function leftValue() As Integer
leftValue = Application.Caller.Offset(-1, -1).Value
End Function
Function getRemainder(eggs As Integer)
crates = Application.WorksheetFunction.Quotient(eggs, 30)
getRemainder = eggs - crates * 30
End Function
Function SumPrice(eggs As Integer, rate As Double)
Application.Volatile True
getRemain = eggs + leftValue()
'yesEggs = getRemainder(eggs)
crates = Application.WorksheetFunction.Quotient(getRemain, 30)
SumPrice = crates * rates
End Function