View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Custom function - Help please

Hi Thierry,

Firstly, change:

Delay = Range(Requispour).Value - Range(Livrele).Value

to:
Delay = Requispour.Value - Livrele.Value

You have already declared Requispour and Livrele as ranges.

It is not clear to me what range you are attempting to define in the
expression:

Range(Requispour.Column + 1)


Perhaps you could describe the range in words?

It should also be noted that, if you intend to use your function as a
worksheet function (UDF), the UDF cannot change the format of cells other
than the calling cell.

---
Regards,
Norman



wrote in message
oups.com...
Hello,

I created this function but I don't know why it doesn't work properly.
Any help appreciate.
Thank you.

Regards,
Thierry

Function Tps(Livrele As Range, Requispour As Range)
Dim Delay As Integer
Delay = Range(Requispour).Value - Range(Livrele).Value
If Delay < 0 Then
Range(Requispour.Column + 1).Interior.ColorIndex = 55
Range(Requispour.Column + 1).Font.ColorIndex = 0
Else
Range(Requispour.Column + 1).Interior.ColorIndex = 0
Range(Requispour.Column + 1).Font.ColorIndex = 1
End If
End Function