Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
place code where?
Hello, can someone explain how and where does this code go to get it to work?
Does it go in general macro or do I need to put in a module. Private Function SecondsToTime(byval dSeconds as Double) _ as String SecondsToTime = Format(DateAdd("s", dSeconds, "00:00:00"), "HH:mm:ss") End Function regards Stephen |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
place code where?
On Saturday, September 8, 2012 4:09:38 AM UTC-4, Stephen wrote:
Hello, can someone explain how and where does this code go to get it to work? Does it go in general macro or do I need to put in a module. Private Function SecondsToTime(byval dSeconds as Double) _ as String SecondsToTime = Format(DateAdd("s", dSeconds, "00:00:00"), "HH:mm:ss") End Function regards Stephen It works just fine in a standard module: User Defined Functions (UDFs) are very easy to install and use: 1. ALT-F11 brings up the VBE window 2. ALT-I ALT-M opens a fresh module 3. paste the stuff in and close the VBE window If you save the workbook, the UDF will be saved with it. To remove the UDF: 1. bring up the VBE window as above 2. clear the code out 3. close the VBE window To use the UDF from Excel: =myfunction(A1) To learn more about macros in general, see: http://www.mvps.org/dmcritchie/excel/getstarted.htm or http://www.cpearson.com/excel/Writin...ionsInVBA.aspx for specifics on UDFs I would avoid the Private |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
place code where?
On Saturday, September 8, 2012 3:09:38 AM UTC-5, Stephen wrote:
Hello, can someone explain how and where does this code go to get it to work? Does it go in general macro or do I need to put in a module. Private Function SecondsToTime(byval dSeconds as Double) _ as String SecondsToTime = Format(DateAdd("s", dSeconds, "00:00:00"), "HH:mm:ss") End Function regards Stephen Assuming your function is OK it needs to go into a REGULAR module. Not a sheet module |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
place code where?
On Saturday, September 8, 2012 6:09:38 PM UTC+10, Stephen wrote:
Hello, can someone explain how and where does this code go to get it to work? Does it go in general macro or do I need to put in a module. Private Function SecondsToTime(byval dSeconds as Double) _ as String SecondsToTime = Format(DateAdd("s", dSeconds, "00:00:00"), "HH:mm:ss") End Function regards Stephen Thank You James & Don this fixes a problem for me much appreciated regards Stephen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to code, AND where to place it !! | Excel Programming | |||
Where to place code that changes a cell value? | Excel Programming | |||
where do i place the code ? | Excel Programming | |||
Wherre best to place code | New Users to Excel | |||
Where to place Code question | Excel Programming |