Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input Boxes & getting tied up in knots with strings!
I am attempting to create a macro that will put the current days date in one cell and then via an input box promt the user to input a number of years in the future and input that date in the cell below the first. I have got as far as below but am having difficulty returning the value of the string for use in a formula in the secnd destination cell. The first date cell is F6, the second is F7, I am not sure I am going about this the reight way, but I have set a formula in cell F7 as follows
=F6+(P1*365.25) I am curious as to how I get the value input from the inputbox into the cell P1, or else if there is an easier way to do this. I note the dateadd function does not allow the option of years addition, otherwise I would use that instead. Sub dateissue() Range("f6") = Format(Date, "dd-mm-yyyy") Dim Message, Title, Default, CERTLIFE As String Message = "Enter Certification Period" ' Set prompt. Title = "Certlifespan" ' Set title. Default = "10" ' Set default. ' Display message, title, and default value. CERTLIFE = InputBox(Message, Title, Default) Range("P1") = String(CERTLIFE, 0) End Sub -- Roger W |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input Boxes & getting tied up in knots with strings!
How about this?
Days = Day(Range("F6")) Months = Month(Range("F6")) Years = Year(Range("F6")) + CertLife Range("F7") = DateValue(Months & "/" & Days & "/" & Years -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input Boxes & getting tied up in knots with strings!
Not sure how to tie it in, when I attach the code to the end of my macro it complains that 'days' is not a defined variable, I suspect it will do the same with months and years also.
-- Roger W "RogerNZ" wrote: I am attempting to create a macro that will put the current days date in one cell and then via an input box promt the user to input a number of years in the future and input that date in the cell below the first. I have got as far as below but am having difficulty returning the value of the string for use in a formula in the secnd destination cell. The first date cell is F6, the second is F7, I am not sure I am going about this the reight way, but I have set a formula in cell F7 as follows =F6+(P1*365.25) I am curious as to how I get the value input from the inputbox into the cell P1, or else if there is an easier way to do this. I note the dateadd function does not allow the option of years addition, otherwise I would use that instead. Sub dateissue() Range("f6") = Format(Date, "dd-mm-yyyy") Dim Message, Title, Default, CERTLIFE As String Message = "Enter Certification Period" ' Set prompt. Title = "Certlifespan" ' Set title. Default = "10" ' Set default. ' Display message, title, and default value. CERTLIFE = InputBox(Message, Title, Default) Range("P1") = String(CERTLIFE, 0) End Sub -- Roger W |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Input Boxes & getting tied up in knots with strings!
So you have got the number of years in P1.
Try in f7 '=Date(year(f6)+p1,month(f6),day(f6)) Regards Chris "RogerNZ" wrote in message ... I am attempting to create a macro that will put the current days date in one cell and then via an input box promt the user to input a number of years in the future and input that date in the cell below the first. I have got as far as below but am having difficulty returning the value of the string for use in a formula in the secnd destination cell. The first date cell is F6, the second is F7, I am not sure I am going about this the reight way, but I have set a formula in cell F7 as follows =F6+(P1*365.25) I am curious as to how I get the value input from the inputbox into the cell P1, or else if there is an easier way to do this. I note the dateadd function does not allow the option of years addition, otherwise I would use that instead. Sub dateissue() Range("f6") = Format(Date, "dd-mm-yyyy") Dim Message, Title, Default, CERTLIFE As String Message = "Enter Certification Period" ' Set prompt. Title = "Certlifespan" ' Set title. Default = "10" ' Set default. ' Display message, title, and default value. CERTLIFE = InputBox(Message, Title, Default) Range("P1") = String(CERTLIFE, 0) End Sub -- Roger W |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Input boxes | Excel Discussion (Misc queries) | |||
How do I add input data in the input ranges in drop down boxes. | Excel Discussion (Misc queries) | |||
Input Boxes | Excel Programming | |||
Can anyone help with input boxes? | Excel Programming | |||
Mask input in input boxes? | Excel Programming |