SOLVED

Formula to output value from a column, or show a text output if more than 1 distinct value in column

Copper Contributor

Hello!

 

So sorry if this has an obvious answer. I've been googling for hours and cannot figure this out so I've decided to ask.

 

In my workbook, I have a sheet containing tables in which the data will automatically be pasted using macro buttons on another sheet. (The macro button opens file browser and prompts them to select a raw data report, macro then pastes it onto the correct table)

 

The tables/data will contain a column with the month, looking just like in the below screenshot.

 

I am simply trying to make a separate cell (example highlighted in yellow below) which will either output the month if there is only one throughout the whole column (e.g. Dec 2022), or simply say >1 month if there is more than one month in the entire column.

 

RVXAC_3-1678848585124.png

 

 

Ideally, the formula could produce the date range if there was multiple months (Ex: Sept 2022 - Feb 2023) but with excel not detecting the text format, etc. etc... it was becoming much too complicated so I would settle for the ">1 month" output. Since I only want to use a single formula, no more vba.

 

 

It's my first time posting on here and my knowledge is very basic. I've so far managed to built quite the intricate macro tool by simply googling but somehow this has really stumped me.

 

Hope my explanations were okay, but if any clarifications needed please, ask away. 

Thanks so much for any help.

Richard

 

4 Replies
best response confirmed by VI_Migration (Silver Contributor)
Solution

@RVXAC You may use the following formula-

=IF(COUNTA(UNIQUE(A2:A15))=1,UNIQUE(A2:A15),">1 Month")

Harun24HR_0-1678859420605.png

 

Hello@Harun24HR 

 
Thanks so much for your reply, this does exactly what I asked for!

 

The one problem is, I forget to mention that I wanted the cell to display "No data" if there was no data in the table.

 

Once again, I tried modifying the formula you have provided but I did not have success in adding this additional feature. Any thoughts on how I can modify the formula?

 

Thanks so much again.
Richard

@Harun24HR


Actually, I think I got it.

 

Your formula helped start me off with the logic of it, and I was able to come up with this formula, which seems to work:

 

=IF(A2=0,"No data imported.",IF(COUNTA(UNIQUE(A2:A15))>1,">1 Month",IF(COUNTA(A2)=1,A2,"No data imported.")))


It may not be pretty, but at least it's working!

Thanks so much again.
Richard

If that help, you can tick mark the answer so that thread can be treated as solved.
1 best response

Accepted Solutions
best response confirmed by VI_Migration (Silver Contributor)
Solution

@RVXAC You may use the following formula-

=IF(COUNTA(UNIQUE(A2:A15))=1,UNIQUE(A2:A15),">1 Month")

Harun24HR_0-1678859420605.png

 

View solution in original post