LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Helpneeded in writing special function, "IsBetween"

I started out using this function and found that I was spending most of my
time getting just the right columns in the formula every place I need it.
The columns are not always adjacent to each other.

Sometimes a VBA function is better.

John

"Bob Phillips" wrote in message
...
John,

Why use VBA when you can do it with a worksheet function

=IF(OR(AND(A1B1,A1<C1),AND(A1<B1,A1C1)),"Yes","N o")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wirt" wrote in message
...
I want to write a VBA function that compares the numeric values in cell1
against the value is cell2 and cell 3, and reports "Yes" if cell1 is

between
cell2 and cell 3, and otherwise "No." Here is a cut & paste of the

function
I;ve written in PERSONAL.XLS (see below).

WHen I enter =IsBetween(A1, B1,C1) in D1 with numeric values in A1, B1,

and
C1 I get a #NAME error in D1. How come?

Function IsBetween(cell1, cell2, cell3) As String
If cell1 cell2 Then
If cell1 < cell3 Then
IsBetween = "Yes"
Else
IsBetween = "No"
End If
ElseIf cell1 < cell2 Then
If cell1 cell3 Then
IsBetween = "Yes"
Else
IsBetween = "No"
End If
End Function


Thanks.

John Wirt








 
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
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Office 2007 "go to special" shortcut function Michele Excel Discussion (Misc queries) 5 August 5th 09 06:24 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Writing "shapes" to disk file Peter Spencer Excel Programming 0 September 9th 03 10:11 AM
"Small" Multi-Dimensional Array Slow Writing To Cell Steve Hieb Excel Programming 2 September 6th 03 03:20 AM


All times are GMT +1. The time now is 11:49 AM.

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

About Us

"It's about Microsoft Excel"