Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Custom function - Help please

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Custom function - Help please


Hello mrjaune,

Change your code to this...


Code:
--------------------
Function Tps(Livrele As Range, Requispour As Range)

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

End Function

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=483356

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Custom function - Help please

you didn't specify the row reference.
Range(Requispour.Column + 1).Interior.ColorIndex = 55

try:
Requispour.Offset(0,1).Interior.ColorIndex = 55

" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Custom function - Help please

Hi Norman,
And thanks for your help.

I want do for example:
Delay = cell H11 - cell F11
and if the result is negative (the result is in cell J11)
I want the cell J11 fill in orange and the result in white.
Otherwise, if the result is positive I want no fill and text in black.
And next I can copy my Tps function to a J12:J650 range.

I can't use a conditional formating because I can't copy the formula to
a range.
I tried it before.

In my mind I want write this formula in cell J11: =Tps(F11,H11)

Regards,
Thierry



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Custom function - Help please

Hi Thierry,

I can't use a conditional formating because I can't copy the formula to
a range.
I tried it before.


Select cells J11:J650
Format | Conditional Formatting
Formula Is =$H11-$F11<0 Fill color: Orange, Font color: White

worked for me.

---
Regards,
Norman



wrote in message
ups.com...
Hi Norman,
And thanks for your help.

I want do for example:
Delay = cell H11 - cell F11
and if the result is negative (the result is in cell J11)
I want the cell J11 fill in orange and the result in white.
Otherwise, if the result is positive I want no fill and text in black.
And next I can copy my Tps function to a J12:J650 range.

I can't use a conditional formating because I can't copy the formula to
a range.
I tried it before.

In my mind I want write this formula in cell J11: =Tps(F11,H11)

Regards,
Thierry



Reply
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
Ned Help W/ Custom Function japorms Excel Worksheet Functions 3 August 14th 06 09:58 PM
Custom Function: Detecting the cell the function is used in g-boy Excel Programming 2 June 11th 05 06:46 PM
Emulate Index/Match combo function w/ VBA custom function Spencer Hutton Excel Worksheet Functions 2 May 2nd 05 05:26 PM
custom function - with built-in function VilMarci Excel Programming 14 January 25th 05 04:15 PM
Adding a custom function to the default excel function list DonutDel Excel Programming 3 November 21st 03 03:41 PM


All times are GMT +1. The time now is 01:45 AM.

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

About Us

"It's about Microsoft Excel"