Adding if statement to arrayformula

cpansewicz

New Member
Joined
Nov 20, 2009
Messages
10
Hi,

I have a formula that pulls two columns of time together into a third column. The formula is in Column S and is:

=arrayformula(
lower(TEXT(Q2,"h:mm AM/PM")&" to "&IF(R2="","",TEXT(R2,"h:mm AM/PM"))))

(for example if both columns are not blank, this generates "6:00 pm to 8:00 pm")

What I would like to happen is in the instance that Col Q = "12:00 PM", then the formula would generate for instance "Noon to 8:00 pm".

Thank you,
Camille
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I had to look it up. ARRAYFORMULA is a Google Sheets function, not an Excel function. Although this isn't an array formula at all, not sure why you're using that.

In Excel, I would do it like this, but I don't know how it will translate to Google Sheets (This is not a Google forum)

=SUBSTITUTE(LOWER(TEXT(Q2,"h:mm AM/PM") & " to " & IF(R2="","",TEXT(R2,"h:mm AM/PM"))),"12:00 pm","Noon")
 
Last edited:
Upvote 0
Hi,

Thank you so much! That is exactly what I was looking for. Yes, sorry I included the "arrayformula" portion. That is from google sheets. It adds the functionality of copying down a formula throughout the sheet.
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top