trying to write a vba code to determine materials required to meet 30 days of stock

%3CLINGO-SUB%20id%3D%22lingo-sub-2458189%22%20slang%3D%22en-US%22%3Etrying%20to%20write%20a%20vba%20code%20to%20determine%20materials%20required%20to%20meet%2030%20days%20of%20stock%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2458189%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3Eneed%20an%20excel%20macro%20vba%20code%20to%20auto%20calculate%20the%20%22Requirement%22%20to%20keep%20the%20days%20of%20stock%20at%20at%20least%2030%20days.%20For%20example%2C%20if%20the%20%22days%20of%20stock%22%20in%20july%20is%20%26gt%3B%3D%2030%20days%20then%20the%20%22requirement%22%20in%20june%20is%200%20however%20if%20the%20%22Days%20of%20Stock%22%20is%20%26lt%3B%2030%20then%20the%20%22requirement%22%20in%20june%20should%20generate%20the%20material%20required%20to%20keep%20it%20at%2030.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EAttached%20is%20the%20file%20and%20snapshot%20of%20my%20code%20so%20far%2C%20any%20assistance%20would%20be%20appreciated%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2458189%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2459522%22%20slang%3D%22de-DE%22%3ESubject%3A%20trying%20to%20write%20a%20vba%20code%20to%20determine%20materials%20required%20to%20meet%2030%20days%20of%20stock%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2459522%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1079622%22%20target%3D%22_blank%22%3E%40coreylameen19%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%224%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Flanguage%2Freference%2Fuser-interface-help%2Fdateadd-function%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EDateAdd%20function%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%224%22%3EReturns%20a%20%3CSTRONG%3EVariant%3C%2FSTRONG%3E%20(%3CSTRONG%3EDate%3C%2FSTRONG%3E)%20containing%20a%20date%20to%20which%20a%20specified%20time%20interval%20has%20been%20added.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Flanguage%2Freference%2Fuser-interface-help%2Fdatediff-function%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CFONT%20size%3D%224%22%3EDateDiff%20function%3C%2FFONT%3E%3C%2FA%3E%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%224%22%3EReturns%20a%20%3CSTRONG%3EVariant%3C%2FSTRONG%3E%20(%3CSTRONG%3ELong%3C%2FSTRONG%3E)%20specifying%20the%20number%20of%20time%20intervals%20between%20two%20specified%20dates.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%224%22%3E%3CSPAN%20class%3D%22VIiyi%22%3E%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3EJust%20for%20additional%20information%2C%20maybe%20it%20will%20help%20you.%3C%2FSPAN%3E%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22JLqJ4b%20ChMk0b%22%3E%3CSPAN%3EIf%20not%2C%20please%20ignore.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%20%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

need an excel macro vba code to auto calculate the "Requirement" to keep the days of stock at at least 30 days. For example, if the "days of stock" in july is >= 30 days then the "requirement" in june is 0 however if the "Days of Stock" is < 30 then the "requirement" in june should generate the material required to keep it at 30.

Attached is the file and snapshot of my code so far, any assistance would be appreciated

1 Reply

@coreylameen19 

 

DateAdd function

Returns a Variant (Date) containing a date to which a specified time interval has been added.

 

DateDiff function

Returns a Variant (Long) specifying the number of time intervals between two specified dates.

 

Just for additional information, maybe it will help you. If not, please ignore.