Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Combination of user defined fucntion and row() function, doesn't seem to work?

There seems to be something weird here.

I have one user defined function, all it does is return the value sent
Function rowTestInteger(r As Integer) As Integer
rowTestInteger = r
End Function

I have 6 cells a1::b3
all with the formula =rowTestInteger(ROW())

results
1 1
2 2
3 3

So far fine

In column a, the conditional format is the same for all three
=rowTestInteger(ROW())=2
=rowTestInteger(ROW())=2
=rowTestInteger(ROW())=2

in Columns b, I change it a bit to
=rowTestInteger(b1)=2
=rowTestInteger(b2)=2
=rowTestInteger(b3)=2

I set the formats to background of red

a2 and b2 BOTH should be red, but only b2 is.
a2=2=ROW(), so it should be red too, but for some reason it is not!!!

-Sal
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Combination of user defined fucntion and row() function, doesn'tseem to work?

I don't know for sure, but here's my guess:

Try putting =row() in a cell (a1). Hit F2, F9, but watch the formula bar.
You'll see this:
={1}

A one element array.

If I changed your UDF to:
Option Explicit
Function rowTestInteger(r As Variant) As Integer
rowTestInteger = Evaluate(r)
End Function

it worked ok.

I'm guessing that even though you see a number in the cell, excel/vba sees it as
an array.


Sally wrote:

There seems to be something weird here.

I have one user defined function, all it does is return the value sent
Function rowTestInteger(r As Integer) As Integer
rowTestInteger = r
End Function

I have 6 cells a1::b3
all with the formula =rowTestInteger(ROW())

results
1 1
2 2
3 3

So far fine

In column a, the conditional format is the same for all three
=rowTestInteger(ROW())=2
=rowTestInteger(ROW())=2
=rowTestInteger(ROW())=2

in Columns b, I change it a bit to
=rowTestInteger(b1)=2
=rowTestInteger(b2)=2
=rowTestInteger(b3)=2

I set the formats to background of red

a2 and b2 BOTH should be red, but only b2 is.
a2=2=ROW(), so it should be red too, but for some reason it is not!!!

-Sal


--

Dave Peterson

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
user defined function tom_mcd Excel Worksheet Functions 1 January 6th 09 06:23 PM
User Defined function - Help makulski Excel Worksheet Functions 8 February 27th 08 09:44 PM
user defined function Pete_T Excel Worksheet Functions 1 December 1st 07 01:03 AM
User Defined Function Samad Excel Discussion (Misc queries) 14 November 16th 05 12:32 PM
Help within user defined function P. Dileepan Excel Programming 1 October 2nd 03 11:35 PM


All times are GMT +1. The time now is 05:45 PM.

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"