Find cell value in range (multiple columns) and return column number.

vineet78

Board Regular
Joined
Oct 22, 2017
Messages
73
Hi

I am trying to find the excel formula which will search a value in Range of cells (say 4-5 columns) and then return the column number.

Any suggestions please?


Regards
Vineet
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
=MATCH("smith",A1:D1,0)

where A1:D1 are the columns being searched and "smith" is the name to search for
 
Upvote 0
"I am trying to find the excel formula which will search a value in Range of cells (say 4-5 columns) and then return the column number."

=MATCH("smith",A1:D1,0)

The value to be searched for is "smith"
The range A1:D1 consiss of 4 columns.

This reflects what you've asked for and works perfectly and returns 2 since I put smith in B1 and column B is column number 2.

If you are getting #N/A then the value you are searchibng for is not in any of the columns.

Supply some example data of what you are searching for and the data you are searching since my solution works.
 
Last edited:
Upvote 0
Yes you are right, actually i was selecting the full columns and not just range.
For example, i chose A:D instead of A1:D1, does that mean we cannot select full columns range in match ?
 
Upvote 0
Selecting whole columns is not advisable as it slows formulas down.
This only works for a given row.
I'll see if I can come up with something for whole columns
 
Last edited:
Upvote 0
I've got something like this already set up.

This works

=MAX(IF(A:D="smith",COLUMN(A:D)-COLUMN(A1)+1))
Array formula, use Ctrl-Shift-Enter
 
Upvote 0
I dont prefer using Array formulae because not many people understand them :)
Thanks for your help.

I am facing another issue with new code, can you please provide your guidance.
Actually I am trying to paste numbers from excel into word document table , Please note that this is table to table pasting but only range of numbers from excel to word.
Do you have any suggestions please in vba.

thanks in advance.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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