Hi,
I`ve got a problem with cells format operations under the Function.
There is the code below and after IF I`d like to clear content of active cell and the cell above or change their color to another but it doesn`t work (but for example merging cells works). The question is why ? It works under Sub but not under Function.
Thanks for help in advance
Excell file attached.Code:Option Explicit Function Odliczanie2(data1a As String) As String Dim data2 As Date Dim data1 As Date Dim data2godzina As Integer Dim data2dzien As Integer Dim roznicaSekundy As Long data2 = Now() If IsDate(data1a) Then data1 = CDate(data1a) roznicaSekundy = DateDiff("s", data2, data1) data2dzien = Int(roznicaSekundy / 86400) data2godzina = Round((roznicaSekundy - (data2dzien * 86400)) / 3600) If roznicaSekundy < 0 Then Odliczanie2 = "PO CZASIE !" Else Odliczanie2 = data2dzien & " d " & data2godzina & " godz " End If Else Range(ActiveCell, ActiveCell.Offset(-1, 0)).Clear 'lub .Interior.ColorIndex = 23 End If End Function
For example column "2" cells F12 and F13.



Reply With Quote
