Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating Boolean Functions

My Problem:

I want to create functions in Excel that can be used in
the exact same way as built-in functions are used.

For example:
to use the AND built-in function all I need to do is to
type the following into a cell:
=AND(TRUE,FALSE) ..... or
=AND(A1,B1), where cell A1 & B1 contains Boolean values.

The following functions do not exist as built-in
functions in Exce: XNOR & NAND. I would like to write
these functions and access them in the exact same manner
as the AND function:
=XNOR(TRUE,FALSE) or XNOR(A1,B1).

Please help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Creating Boolean Functions

Hi:

XNOR(A1,B1) can be written as:

=OR(AND(A1,B1),AND(AND(NOT(A1),NOT(B1))))

NAND(A1,B1) can be written as:

=NOT(AND(A1,B1))

These can quite easily be written as UDFs.

Function XNOR(A as Boolean, B as Boolean) As Boolean
XNOR = (A And B) Or (Not A And Not B)
End Function

Function NAND(A as Boolean, B as Boolean) As Boolean)
NAND = Not (A And B)
End Function

Regards,

Vasant.


"Professor James E. Hicks" wrote in
message ...
My Problem:

I want to create functions in Excel that can be used in
the exact same way as built-in functions are used.

For example:
to use the AND built-in function all I need to do is to
type the following into a cell:
=AND(TRUE,FALSE) ..... or
=AND(A1,B1), where cell A1 & B1 contains Boolean values.

The following functions do not exist as built-in
functions in Exce: XNOR & NAND. I would like to write
these functions and access them in the exact same manner
as the AND function:
=XNOR(TRUE,FALSE) or XNOR(A1,B1).

Please help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Creating Boolean Functions

Nice Vasant!

Liked it so much, I extended to multiple arguments

Function XNOR(ParamArray args()) As Boolean
Dim i As Long
Dim params1, params2

For i = LBound(args) + 1 To UBound(args)
params1 = args(i - 1) And args(i)
params2 = Not args(i - 1) And Not args(i)
Next i

XNOR = params1 Or params2
End Function



Function NAND(A As Boolean, B As Boolean) As Boolean
Dim i As Long
Dim params1

For i = LBound(args) + 1 To UBound(args)
params1 = args(i - 1) And args(i)
Next i

NAND = Not params1
End Function

--

HTH

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

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Hi:

XNOR(A1,B1) can be written as:

=OR(AND(A1,B1),AND(AND(NOT(A1),NOT(B1))))

NAND(A1,B1) can be written as:

=NOT(AND(A1,B1))

These can quite easily be written as UDFs.

Function XNOR(A as Boolean, B as Boolean) As Boolean
XNOR = (A And B) Or (Not A And Not B)
End Function

Function NAND(A as Boolean, B as Boolean) As Boolean)
NAND = Not (A And B)
End Function

Regards,

Vasant.


"Professor James E. Hicks" wrote in
message ...
My Problem:

I want to create functions in Excel that can be used in
the exact same way as built-in functions are used.

For example:
to use the AND built-in function all I need to do is to
type the following into a cell:
=AND(TRUE,FALSE) ..... or
=AND(A1,B1), where cell A1 & B1 contains Boolean values.

The following functions do not exist as built-in
functions in Exce: XNOR & NAND. I would like to write
these functions and access them in the exact same manner
as the AND function:
=XNOR(TRUE,FALSE) or XNOR(A1,B1).

Please help





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Creating Boolean Functions

or even ...

Function XNOR(ParamArray args()) As Boolean
Dim i As Long
Dim params1, params2

params1 = args(1)
For i = LBound(args) + 1 To UBound(args)
params1 = params1 And args(i)
params2 = Not params2 And Not args(i)
Next i

XNOR = params1 Or params2
End Function



Function NAND(A As Boolean, B As Boolean) As Boolean
Dim i As Long
Dim params1, params2

params1 = args(1)
For i = LBound(args) + 1 To UBound(args)
params1 = params1 And args(i)
Next i

NAND = Not params1
End Function


--

HTH

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

"Bob Phillips" wrote in message
...
Nice Vasant!

Liked it so much, I extended to multiple arguments

Function XNOR(ParamArray args()) As Boolean
Dim i As Long
Dim params1, params2

For i = LBound(args) + 1 To UBound(args)
params1 = args(i - 1) And args(i)
params2 = Not args(i - 1) And Not args(i)
Next i

XNOR = params1 Or params2
End Function



Function NAND(A As Boolean, B As Boolean) As Boolean
Dim i As Long
Dim params1

For i = LBound(args) + 1 To UBound(args)
params1 = args(i - 1) And args(i)
Next i

NAND = Not params1
End Function

--

HTH

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

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Hi:

XNOR(A1,B1) can be written as:

=OR(AND(A1,B1),AND(AND(NOT(A1),NOT(B1))))

NAND(A1,B1) can be written as:

=NOT(AND(A1,B1))

These can quite easily be written as UDFs.

Function XNOR(A as Boolean, B as Boolean) As Boolean
XNOR = (A And B) Or (Not A And Not B)
End Function

Function NAND(A as Boolean, B as Boolean) As Boolean)
NAND = Not (A And B)
End Function

Regards,

Vasant.


"Professor James E. Hicks" wrote

in
message ...
My Problem:

I want to create functions in Excel that can be used in
the exact same way as built-in functions are used.

For example:
to use the AND built-in function all I need to do is to
type the following into a cell:
=AND(TRUE,FALSE) ..... or
=AND(A1,B1), where cell A1 & B1 contains Boolean values.

The following functions do not exist as built-in
functions in Exce: XNOR & NAND. I would like to write
these functions and access them in the exact same manner
as the AND function:
=XNOR(TRUE,FALSE) or XNOR(A1,B1).

Please help







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Creating Boolean Functions

Thanks for the nice enhancement, Bob -- I just didn't have the energy to
come up with a multi-argument solution! Let's hope the OP appreciates it.

Regards,

Vasant.

"Bob Phillips" wrote in message
...
or even ...

Function XNOR(ParamArray args()) As Boolean
Dim i As Long
Dim params1, params2

params1 = args(1)
For i = LBound(args) + 1 To UBound(args)
params1 = params1 And args(i)
params2 = Not params2 And Not args(i)
Next i

XNOR = params1 Or params2
End Function



Function NAND(A As Boolean, B As Boolean) As Boolean
Dim i As Long
Dim params1, params2

params1 = args(1)
For i = LBound(args) + 1 To UBound(args)
params1 = params1 And args(i)
Next i

NAND = Not params1
End Function


--

HTH

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

"Bob Phillips" wrote in message
...
Nice Vasant!

Liked it so much, I extended to multiple arguments

Function XNOR(ParamArray args()) As Boolean
Dim i As Long
Dim params1, params2

For i = LBound(args) + 1 To UBound(args)
params1 = args(i - 1) And args(i)
params2 = Not args(i - 1) And Not args(i)
Next i

XNOR = params1 Or params2
End Function



Function NAND(A As Boolean, B As Boolean) As Boolean
Dim i As Long
Dim params1

For i = LBound(args) + 1 To UBound(args)
params1 = args(i - 1) And args(i)
Next i

NAND = Not params1
End Function

--

HTH

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

"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Hi:

XNOR(A1,B1) can be written as:

=OR(AND(A1,B1),AND(AND(NOT(A1),NOT(B1))))

NAND(A1,B1) can be written as:

=NOT(AND(A1,B1))

These can quite easily be written as UDFs.

Function XNOR(A as Boolean, B as Boolean) As Boolean
XNOR = (A And B) Or (Not A And Not B)
End Function

Function NAND(A as Boolean, B as Boolean) As Boolean)
NAND = Not (A And B)
End Function

Regards,

Vasant.


"Professor James E. Hicks" wrote

in
message ...
My Problem:

I want to create functions in Excel that can be used in
the exact same way as built-in functions are used.

For example:
to use the AND built-in function all I need to do is to
type the following into a cell:
=AND(TRUE,FALSE) ..... or
=AND(A1,B1), where cell A1 & B1 contains Boolean values.

The following functions do not exist as built-in
functions in Exce: XNOR & NAND. I would like to write
these functions and access them in the exact same manner
as the AND function:
=XNOR(TRUE,FALSE) or XNOR(A1,B1).

Please help










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Creating Boolean Functions

You have some nice help writing the functions, but I think in order to
access them from the list of functions, you will need to create an add-in.
"Professor James E. Hicks" wrote in
message ...
My Problem:

I want to create functions in Excel that can be used in
the exact same way as built-in functions are used.

For example:
to use the AND built-in function all I need to do is to
type the following into a cell:
=AND(TRUE,FALSE) ..... or
=AND(A1,B1), where cell A1 & B1 contains Boolean values.

The following functions do not exist as built-in
functions in Exce: XNOR & NAND. I would like to write
these functions and access them in the exact same manner
as the AND function:
=XNOR(TRUE,FALSE) or XNOR(A1,B1).

Please help



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Creating Boolean Functions

Mike,

<<You have some nice help writing the functions, but I think in order to
access them from the list of functions, you will need to create an add-in.

No, just make sure that they are public.

Regards,
Kevin




"Mike Fogleman" wrote in message
...
You have some nice help writing the functions, but I think in order to
access them from the list of functions, you will need to create an add-in.
"Professor James E. Hicks" wrote in
message ...
My Problem:

I want to create functions in Excel that can be used in
the exact same way as built-in functions are used.

For example:
to use the AND built-in function all I need to do is to
type the following into a cell:
=AND(TRUE,FALSE) ..... or
=AND(A1,B1), where cell A1 & B1 contains Boolean values.

The following functions do not exist as built-in
functions in Exce: XNOR & NAND. I would like to write
these functions and access them in the exact same manner
as the AND function:
=XNOR(TRUE,FALSE) or XNOR(A1,B1).

Please help





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
Looking for BOOLEAN ALGEBRA functions (specifically XOR) RL Jones Excel Worksheet Functions 12 March 24th 17 07:33 AM
Creating Nested Functions Debra Lisa Excel Discussion (Misc queries) 3 August 26th 07 01:16 PM
creating functions grumpy Excel Worksheet Functions 4 July 14th 06 09:31 AM
creating new functions Peter R Knight Excel Worksheet Functions 3 September 19th 05 02:03 PM
Creating a functions Kimi Excel Worksheet Functions 1 April 8th 05 05:27 AM


All times are GMT +1. The time now is 08:48 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"