M
moon
Hi Reader
how to using Function update cell value ?
e.g.Update_cell work , but Function xHoliday now work.
Function xHoliday(HolidayResult As Range, loDate As Date, ByVal loOffset As
Long) As Date
'~~ 2005/08/04 eric.leung
'~~ if input value no changed, this function will not call.
On Error GoTo xerr
Dim holidaySheet As Variant
Dim i As Long
Dim found As Boolean
Dim cntHoliday As Long
Dim cell As Range
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
' Call Update_cell(Str(cntHoliday))
Set cell = Worksheets("Holiday").Range("F2")
cell.Value = 10
Exit Function
xerr:
MsgBox Err.Number & " " & Err.Description
End Function
Sub Update_cell()
Dim holidaySheet As Variant
Set holidaySheet = Sheets("Holiday")
holidaySheet.Range("i2").Value = "TTT"
End Sub
how to using Function update cell value ?
e.g.Update_cell work , but Function xHoliday now work.
Function xHoliday(HolidayResult As Range, loDate As Date, ByVal loOffset As
Long) As Date
'~~ 2005/08/04 eric.leung
'~~ if input value no changed, this function will not call.
On Error GoTo xerr
Dim holidaySheet As Variant
Dim i As Long
Dim found As Boolean
Dim cntHoliday As Long
Dim cell As Range
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
' Call Update_cell(Str(cntHoliday))
Set cell = Worksheets("Holiday").Range("F2")
cell.Value = 10
Exit Function
xerr:
MsgBox Err.Number & " " & Err.Description
End Function
Sub Update_cell()
Dim holidaySheet As Variant
Set holidaySheet = Sheets("Holiday")
holidaySheet.Range("i2").Value = "TTT"
End Sub