Another excel question please

Author
Discussion

audi321

Original Poster:

5,438 posts

218 months

Wednesday 19th June
quotequote all
Hi, if I wanted to build an if statement into the following, what am I doing wrong?

=A1&(IF B1<1,"Yes",C1)

Hopefully you can see what I'm trying to do? But basically have the content of A1 and, if B1 is less than 1, then Yes, if not, C1.

I'm probably doing this wrong, but if there's an easier way?

Zetec-S

6,206 posts

98 months

Wednesday 19th June
quotequote all
Looks like you're just missing some parentheses...

=A1&(IF(B1<1,"Yes",C1))

audi321

Original Poster:

5,438 posts

218 months

Wednesday 19th June
quotequote all
Zetec-S said:
Looks like you're just missing some parentheses...

=A1&(IF(B1<1,"Yes",C1))
Ah yes perfect thank you, that worked a treat.

audi321

Original Poster:

5,438 posts

218 months

Wednesday 19th June
quotequote all
Totally separate (but related) question, but is it possible to have a Macro run (called Macro1) instead of the 'Yes'?

paulrockliffe

15,942 posts

232 months

Wednesday 19th June
quotequote all
Don't think you can call a Macro with a formula, but it's 2024 and even Microsoft have put VBA in the bin, so bear in mind that there's probably better ways of doing this if you're having to resort to Macros.

If you're going to learn Excel Formulas now, you might as well put Power Query into Google and learn that instead, unless your data is genuinely unstructured, which it won't be, then you'll have far more joy there.

audi321

Original Poster:

5,438 posts

218 months

Wednesday 19th June
quotequote all
Understood and thanks. Seems power query is a little too advanced for what I was looking for but thanks anyways.

MustangGT

12,020 posts

285 months

Wednesday 19th June
quotequote all
Zetec-S said:
Looks like you're just missing some parentheses...

=A1&(IF(B1<1,"Yes",C1))
Could also just have moved the fist open parenthesis to after the IF instead of before.

nickd01

626 posts

220 months

Wednesday 19th June
quotequote all
audi321 said:
Totally separate (but related) question, but is it possible to have a Macro run (called Macro1) instead of the 'Yes'?
Yes, but the macro needs to be a function. For example:

Public Function Test() As String
Test = "Function"
End Function

Then in a formula just put
=IF(1>2,"No",Test())


Zetec-S

6,206 posts

98 months

Wednesday 19th June
quotequote all
MustangGT said:
Zetec-S said:
Looks like you're just missing some parentheses...

=A1&(IF(B1<1,"Yes",C1))
Could also just have moved the fist open parenthesis to after the IF instead of before.
Lol yes, missed that biggringetmecoat