![]() |
Use VBA functions in a worksheet?
Is it possible to use VBA functions in a worksheet? I'd like to use the Dateadd() function on a
worksheet. Jeff |
Use VBA functions in a worksheet?
Jeff,
You don't need it. Try this as a formula: =NOW()+1 Robin Hammond www.enhanceddatasystems.com "Jeff" wrote in message ... Is it possible to use VBA functions in a worksheet? I'd like to use the Dateadd() function on a worksheet. Jeff |
Use VBA functions in a worksheet?
You can create a user defined function.
Public Function MyDateAdd(arg1, arg2, arg3, arg4) as date MyDateAdd = datadd(arg1, arg2, arg3, arg4) end function -- HTH... Jim Thomlinson "Jeff" wrote: Is it possible to use VBA functions in a worksheet? I'd like to use the Dateadd() function on a worksheet. Jeff |
Use VBA functions in a worksheet?
mmm, that won't work. I was trying to calculate the age of a list of people given their date of
birth. I ended up using some year, month, and day functions. Assuming the date of birth is in column A, this should calculate the correct age to the day =(YEAR(TODAY()) - YEAR(A1)) - ((MONTH(TODAY())*100 + DAY(TODAY())) < (MONTH(A1)*100 + DAY(A1))) If anyone knows a better way to do this please post it. I just wanted a formula I could drag down a list of birth dates without writing a VBA procedure. Jeff "Robin Hammond" wrote in message ... Jeff, You don't need it. Try this as a formula: =NOW()+1 Robin Hammond www.enhanceddatasystems.com "Jeff" wrote in message ... Is it possible to use VBA functions in a worksheet? I'd like to use the Dateadd() function on a worksheet. Jeff |
Use VBA functions in a worksheet?
Jeff -
... I was trying to calculate the age of a list of people given their date of birth. ... < You will likely find some useful techniques he http://www.cpearson.com/excel/datetime.htm - Mike www.mikemiddleton.com |
Use VBA functions in a worksheet?
Sounds like you need DateDif. It isn't documented by MS for some reason, but
Chip Pearson has a page on it at http://www.cpearson.com/excel/datedif.htm -- HTH RP (remove nothere from the email address if mailing direct) "Jeff" wrote in message ... mmm, that won't work. I was trying to calculate the age of a list of people given their date of birth. I ended up using some year, month, and day functions. Assuming the date of birth is in column A, this should calculate the correct age to the day =(YEAR(TODAY()) - YEAR(A1)) - ((MONTH(TODAY())*100 + DAY(TODAY())) < (MONTH(A1)*100 + DAY(A1))) If anyone knows a better way to do this please post it. I just wanted a formula I could drag down a list of birth dates without writing a VBA procedure. Jeff "Robin Hammond" wrote in message ... Jeff, You don't need it. Try this as a formula: =NOW()+1 Robin Hammond www.enhanceddatasystems.com "Jeff" wrote in message ... Is it possible to use VBA functions in a worksheet? I'd like to use the Dateadd() function on a worksheet. Jeff |
Use VBA functions in a worksheet?
Please answer the question: IS IT POSSIBLE TO USE VBA FUNCTIONS IN A
WORKSHEET. Everyone has focused on the use of the DateAdd function, but there are hundreds of other VBA functions that are not supported by worksheet functions. Jim Thomlinson came the closest - create a user-defined function. But then, what magic incantations do I have to invoke to use it in a cell formula? Thanks. -- Ted "Jeff" wrote: Is it possible to use VBA functions in a worksheet? I'd like to use the Dateadd() function on a worksheet. Jeff |
Use VBA functions in a worksheet?
"Jim Thomlinson came the closest - create a user-defined function. But then, what magic incantations do I have to invoke to use it in a cell formula? Thanks." If you put the code in a regular module in the desired worksheet, or in an add-in if you want the function available to all/several worksheets, you call the function like you would any other worksheet function =mydateadd(arg1,arg2,arg3,arg4) -- MrShorty ------------------------------------------------------------------------ MrShorty's Profile: http://www.excelforum.com/member.php...o&userid=22181 View this thread: http://www.excelforum.com/showthread...hreadid=490940 |
Use VBA functions in a worksheet?
Sorry, if we think it is better to use worksheet functions we will say so.
That is our prerogative. If w/s functions will not work, that should be stated, and why, as we may know how to make it work. -- HTH RP (remove nothere from the email address if mailing direct) "TedMi" wrote in message ... Please answer the question: IS IT POSSIBLE TO USE VBA FUNCTIONS IN A WORKSHEET. Everyone has focused on the use of the DateAdd function, but there are hundreds of other VBA functions that are not supported by worksheet functions. Jim Thomlinson came the closest - create a user-defined function. But then, what magic incantations do I have to invoke to use it in a cell formula? Thanks. -- Ted "Jeff" wrote: Is it possible to use VBA functions in a worksheet? I'd like to use the Dateadd() function on a worksheet. Jeff |
All times are GMT +1. The time now is 05:26 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com