writing my own Function - cell to contain "A" or "B"

  • Thread starter Thread starter Kristen
  • Start date Start date
K

Kristen

I know this is a simple question and I'm sorry, but I just can't find
the answer.
I'm trying my hand at writing my own Function.
I'm wanting one cell to contain either "A" or "B" and nothing else,
the rest are numbers.

So that I can have something like this:

Function Test(AorB, Other1, Other2, etc)
IF AorB = "A" then
Other1 + Other2
Else: Other1 - Other2

Thankyou in advance
Kristen
 
I know this is a simple question and I'm sorry, but I just can't find
the answer.
I'm trying my hand at writing my own Function.
I'm wanting one cell to contain either "A" or "B" and nothing else,
the rest are numbers.

So that I can have something like this:

Function Test(AorB, Other1, Other2, etc)
IF AorB = "A" then
Other1 + Other2
Else: Other1 - Other2

Thankyou in advance
Kristen
If I understand you correctly, assuming that the A or B value is in cell A1,
Other1 in cell B1, and Other2 in cell C1, try:

=IF(OR(A1="A",A1="B"),B1+C1,B1-C1)

Hope this helps!
 
Thanks for your reply.
Sorry, but does this work in VBA?

What I'm trying to do is write my own worksheet function - using VBA.
I want it to do similar to what you have suggested.

Thankyou
Kristen
 
...but does this work in VBA?

Unfortunately, I'm not familiar with VBA. But it's very likely that it can
be done. Hopefully someone here will be able to help.

Cheers!
 
Back
Top