Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Help in writing a function

  Asked By: Emily    Date: Dec 14    Category: MS Office    Views: 751
  

Im new to Visual Basics, all i know is from reading a few help
website...
im from israel, and i want to make a function that tell's me if a
specific date is a holiday.
the problem is that hebrew holidays go only by hebrew dates, and
hebrew dates are strings in hebrew...
i downloaded a function for excel that turns a numeric like
2/10/2006 to a hebrew date (a string).
and i cant seem to use it in my function, and i dont know why.
thanx for the help

What i put in the Excel cell: =holiday("2/10/2006")

The Function:
Public Function holiday(NumDate) As String
Dim HebDate As String
HebDate = WorksheetFunction.HebrewDate(NumDate)
Hanuca = "hello"
If HebDate = Hanuca Then holiday = True Else holiday = False
End Function

i just tried to see if it works, by what i understand im suppose to
get "False" in Excel, and what i get instead is #VALUE!

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Ginger Snyder     Answered On: Dec 14


I cannot test your macro as I do not have the HebrewDate worksheet function.

Assuming you have that function, you may have put  the macro in the wrong
place. It must be in a module rather than in a worksheet or workbook object.
Only modules publish their functions so they can be used in the worksheet.

 
Answer #2    Answered By: Jimmy Abp     Answered On: Dec 14

Yea i did it threw a module.. i checked if the function  is working
first by using numbers and not string, i did a simple check and the
function worked. but when is summoned the hebrewdate function from
the worksheet is started having problems.
is there a way in visual  basics to see the steps the function does?
so i can trace the problem?

 
Answer #3    Answered By: Rickey Scott     Answered On: Dec 14

You can set a breakpoint in the function  by clicking in the left margin. It
appears as brown dot and the macro is supposed to stop when it gets there.
When this happens you can put  the mouse cursor on the name of any variable and
its value appears as a pop-up. You then step the through the macro with f8.

Rather than call the macro from the spreadsheet you can enter a command in the
immediate window (lower right in the editor) and it will start the macro.

 
Didn't find what you were looking for? Find more on Help in writing a function Or get search suggestion and latest updates.




Tagged: