Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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


  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 1,119
Default 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



  #4   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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






  #5   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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




  #6   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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








  #7   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 52
Default 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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #9   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 11,272
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
worksheet functions Nkumar Excel Worksheet Functions 4 July 18th 08 10:58 AM
Using VBA Functions in a worksheet Gary''s Student Excel Programming 4 September 6th 05 04:57 PM
Worksheet functions Nadji New Users to Excel 2 June 10th 05 06:25 PM
worksheet functions Nadji Excel Worksheet Functions 1 June 10th 05 05:25 PM
Public Functions As Worksheet Available Functions Steve King Excel Programming 3 February 12th 05 07:55 PM


All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"