![]() |
hollidays
Hi again,
I´ve done this in vbscript: [KOD]longfred = DateAdd("d", -2, esterday) esterafton = DateAdd("d", -1, esterday) estermond = DateAdd("d", 1, esterday) flygdag = DateAdd("d", 39, esterday) pingstd = DateAdd("d", 49, esterday) pingstaftn = DateAdd("d", -1, pingstd) [/KOD] Is it possible to do that in Excek/VBA?? Thanks in advance //Peter |
hollidays
Peter,
You can use the same code. You have the advantage of being able to declare you variables as dates to reduce errors. Dim LongFred As Date Dim EsterAfton As Date etc NickHK "peter the swede" wrote in message oups.com... Hi again, I´ve done this in vbscript: [KOD]longfred = DateAdd("d", -2, esterday) esterafton = DateAdd("d", -1, esterday) estermond = DateAdd("d", 1, esterday) flygdag = DateAdd("d", 39, esterday) pingstd = DateAdd("d", 49, esterday) pingstaftn = DateAdd("d", -1, pingstd) [/KOD] Is it possible to do that in Excek/VBA?? Thanks in advance //Peter |
hollidays
Thanks Nick,
a little more help please: If I´ve this function: Code:
Function Esterday(Year As Integer, Optional Returtyp As Integer) As can you give me an exemple what it looks like? Thanks in advance //Peter NickHK skrev: Peter, You can use the same code. You have the advantage of being able to declare you variables as dates to reduce errors. Dim LongFred As Date Dim EsterAfton As Date etc NickHK "peter the swede" wrote in message oups.com... Hi again, I´ve done this in vbscript: [KOD]longfred = DateAdd("d", -2, esterday) esterafton = DateAdd("d", -1, esterday) estermond = DateAdd("d", 1, esterday) flygdag = DateAdd("d", 39, esterday) pingstd = DateAdd("d", 49, esterday) pingstaftn = DateAdd("d", -1, pingstd) [/KOD] Is it possible to do that in Excek/VBA?? Thanks in advance //Peter |
hollidays
Peter,
If you make this function Public in a module, then you can call it a worksheet cell. From Excel press Alt+F11 to open the VBA IDE. On the project tree for your workbook, right-click Insert Module. Paste this function code. Change the signature to read: Public Function Esterday(Year As Integer, Optional Returtyp As Integer) As Variant Then from a cell in your worksheet, type (without the quote marks) : "=Esterday(D11,1)" NickHK "peter the swede" wrote in message ps.com... Thanks Nick, a little more help please: If I´ve this function: Code:
Function Esterday(Year As Integer, Optional Returtyp As Integer) As can you give me an exemple what it looks like? Thanks in advance //Peter NickHK skrev: Peter, You can use the same code. You have the advantage of being able to declare you variables as dates to reduce errors. Dim LongFred As Date Dim EsterAfton As Date etc NickHK "peter the swede" wrote in message oups.com... Hi again, I´ve done this in vbscript: [KOD]longfred = DateAdd("d", -2, esterday) esterafton = DateAdd("d", -1, esterday) estermond = DateAdd("d", 1, esterday) flygdag = DateAdd("d", 39, esterday) pingstd = DateAdd("d", 49, esterday) pingstaftn = DateAdd("d", -1, pingstd) [/KOD] Is it possible to do that in Excek/VBA?? Thanks in advance //Peter |
hollidays
Thx NickHK
two more questions please:-) 1) what do 1 means in "=Esterday(D11,1)" 2) can I write: "=Esterday(holliday!D11,1)" NickHK skrev: Peter, If you make this function Public in a module, then you can call it a worksheet cell. From Excel press Alt+F11 to open the VBA IDE. On the project tree for your workbook, right-click Insert Module. Paste this function code. Change the signature to read: Public Function Esterday(Year As Integer, Optional Returtyp As Integer) As Variant Then from a cell in your worksheet, type (without the quote marks) : "=Esterday(D11,1)" NickHK "peter the swede" wrote in message ps.com... Thanks Nick, a little more help please: If I´ve this function: Code:
Function Esterday(Year As Integer, Optional Returtyp As Integer) As And have the year in cell D11 on page hollidays can you give me an exemple what it looks like? Thanks in advance //Peter NickHK skrev: Peter, You can use the same code. You have the advantage of being able to declare you variables as dates to reduce errors. Dim LongFred As Date Dim EsterAfton As Date etc NickHK "peter the swede" wrote in message oups.com... Hi again, I´ve done this in vbscript: [KOD]longfred = DateAdd("d", -2, esterday) esterafton = DateAdd("d", -1, esterday) estermond = DateAdd("d", 1, esterday) flygdag = DateAdd("d", 39, esterday) pingstd = DateAdd("d", 49, esterday) pingstaftn = DateAdd("d", -1, pingstd) [/KOD] Is it possible to do that in Excek/VBA?? Thanks in advance //Peter |
hollidays
Peter,
1 - Your function has 2 arguments, one Optional. So the call to your function matches the function's signature. 2 - You can pass any valid cell reference that contains the Year you want to get Easter day for. You can also pass a value ; "=Esterday(6,1)" NickHK "peter the swede" wrote in message ups.com... Thx NickHK two more questions please:-) 1) what do 1 means in "=Esterday(D11,1)" 2) can I write: "=Esterday(holliday!D11,1)" NickHK skrev: Peter, If you make this function Public in a module, then you can call it a worksheet cell. From Excel press Alt+F11 to open the VBA IDE. On the project tree for your workbook, right-click Insert Module. Paste this function code. Change the signature to read: Public Function Esterday(Year As Integer, Optional Returtyp As Integer) As Variant Then from a cell in your worksheet, type (without the quote marks) : "=Esterday(D11,1)" NickHK "peter the swede" wrote in message ps.com... Thanks Nick, a little more help please: If I´ve this function: Code:
Function Esterday(Year As Integer, Optional Returtyp As Integer) As And have the year in cell D11 on page hollidays can you give me an exemple what it looks like? Thanks in advance //Peter NickHK skrev: Peter, You can use the same code. You have the advantage of being able to declare you variables as dates to reduce errors. Dim LongFred As Date Dim EsterAfton As Date etc NickHK "peter the swede" wrote in message oups.com... Hi again, I´ve done this in vbscript: [KOD]longfred = DateAdd("d", -2, esterday) esterafton = DateAdd("d", -1, esterday) estermond = DateAdd("d", 1, esterday) flygdag = DateAdd("d", 39, esterday) pingstd = DateAdd("d", 49, esterday) pingstaftn = DateAdd("d", -1, pingstd) [/KOD] Is it possible to do that in Excek/VBA?? Thanks in advance //Peter |
All times are GMT +1. The time now is 03:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com