LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default function need to return value and update one cell value

Below function can return non-holiday date, I want to return how many
holiday found.
Variable HolidayResult to be update as long integer. But , I try can not
able to return the non-holiday by coding HolidayResult.Address.Value =
cntHoliday

HolidayResult. Address is "$F$4' in my test case.

Holiday Sheet format
Column A - Date value
Column B - Yes = Holiday, No = Non-Holiday

Function xHoliday(HolidayResult As Range, loDate As Date, ByVal loOffset As
Long) As Date
'~~ if input value no changed, this function will not call.
Dim HolidaySheet As Variant
Dim i As Long
Dim found As Boolean
Dim cntHoliday As Long
cntHoliday = 0
found = False
xHoliday = loDate - loOffset
Set HolidaySheet = Sheets("Holiday")
i = 1001
Do

If HolidaySheet.Range("A" & i) = xHoliday Then
found = True
Else
i = i - 1
End If

Loop Until found = True

'~~ When return date still holiday, skip it , until Holiday = "no"
found = False
Do

If Trim(UCase(HolidaySheet.Range("B" & i))) = "NO" Then
found = True
Else
xHoliday = xHoliday - 1
cntHoliday = cntHoliday + 1
i = i - 1
End If

Loop Until found = True
' MsgBox HolidayResult.Address
HolidayResult.Address.Value = cntHoliday
End Function


 
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
how do I get the if function to return a blank cell, not 0? JoeCars Charts and Charting in Excel 2 January 18th 08 04:51 PM
How to make a function in a cell update Brian Beck Excel Discussion (Misc queries) 1 December 6th 06 03:34 PM
A function to return the value of a blank cell Haz Excel Worksheet Functions 1 July 16th 06 06:38 PM
function CELL() to return the formula in the referenced cell Streep Excel Worksheet Functions 3 August 20th 05 10:24 PM
How do I use a function to return the address of a cell? ren6175 Excel Worksheet Functions 6 April 21st 05 03:13 PM


All times are GMT +1. The time now is 02:25 PM.

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

About Us

"It's about Microsoft Excel"