Displaying name of column if a cell contains specific text

thomasb82

New Member
Joined
Nov 22, 2016
Messages
12
Hey guys, bare with me as this is a bit complicated to explain. I basically have a document that contains a long list of subdepartments in one sheet and a long list of people info in rows in another sheet where the subdeparment is displayed to every person. My goal is to add a column beside the subdeparment cell that displays which head deparment it belongs to. I have a separate sheet that contains all the subcomparments in columns, with the name of the head deparment, like this(with head department in bold and subdepartments below:

Engineering HR IT
mechanic staffing production
gears recruting smartphones
etc...

then i have another sheet that contains rows of people info that only shows their subdepartment(recruiting in this instance):

Daffy Duck streetadress jobtitle recruiting

now i want the cell next to "recruting" to display"HR" if it contains any of the text in the HR column.

So basically i want the code to search every cell in the subdepartment sheet and shows the corresponding main department (HR, Enigneering etc) in the people sheet.

Am i making sense? anyone got an idea? been wrapping my head around this for a while now, would appreciate some help...
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
This could be a easy answer if you were to provide some specific details.
You have given no specific details.

You mention two or more sheets but give no sheet names.
And you mention several different columns but give no column numbers

You need to provide details like:

I have data on sheet named "Master" and in column(2) I have...

And I want to do this to sheet named "Next" when a Vba script sees this in column "5"

It' impossible with such limited details for me to help you.

Go to the store and get me some food is unspecific.
Go to "Publics" and get me "5 Red Apples" is specific.
 
Upvote 0
See if you can adapt this (but you will need to be consistent with your spelling - you have "recruiting" in one spot and "recruting" in another :))
This suggestion will also only work if there are no duplicate sub-department names.
Post back with details if you have any further difficulties.


Excel 2016 (Windows) 32 bit
ABC
1EngineeringHRIT
2mechanicstaffingproduction
3gearsrecruitingsmartphones
Dept List




Excel 2016 (Windows) 32 bit
ABCDE
2Daffy DuckstreetadressjobtitlerecruitingHR
Staff
Cell Formulas
RangeFormula
E2=INDEX('Dept List'!$A$1:$C$1,SUMPRODUCT(('Dept List'!$A$1:$C$3=D2)*(COLUMN('Dept List'!$A$1:$C$3)-COLUMN('Dept List'!$A$1)+1)))
 
Upvote 0
Hey peter, thanks for the input. Having i hard time trying to adjust this to my document. would it be too much to ask if you had a look at the file above and adjusted the formula to fit that one? then it would be eaasier for me to grasp the formula and context. would be much appreiciated.

thanks, thomas
 
Upvote 0
In C2 of Sheet1
=INDEX(Sheet2!$A$1:$C$1,SUMPRODUCT((Sheet2!$A$1:$C$20=B2)*(COLUMN(Sheet2!$A$1:$C$20)-COLUMN(Sheet2!$A$1)+1)))

Then copy that formula down.
 
Upvote 0
ah thanks, running into an error but think thats because of my excel being in swedish. will let ya know if i get it to work :)
 
Upvote 0
yep, it was an translation issue. apparently swedish excel uses semcolons instead of commas. thanks again, its working fine now!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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