Copy Column Header if cell in column meets criteria

flds

Board Regular
Joined
Jun 19, 2008
Messages
78
Office Version
  1. 2021
Platform
  1. Windows
Hello,

I am trying to figure out a formula that gives me the header result.

example:
H2 the result should be DEF
H3 the result should be FGH
H4 the result should be DEF
H5 the result should be BCD
H6 the result should be ABC
H7 the result should be ABC

Excel Spreadsheet
A B C D E F G H
1 ABC BCD CDE DEF EFG FGH
2 -1 -1 -5 9 -1 -1 =IF(B3:G3>0,B2:G2,"")
3 -1 -1 -5 -1 -1 9
4 -1 -1 -1 5 -1 -1
5 -2 8 -6 4 -2 -2
6 6 -1 -1 -1 -1 -2
7 4 -3 -7 3 -3 6

I hope someone could help me in this formula.

Thanks
FLDS
 
Hi Valko and Branco
Thank you for the formulas. Both the formulas seem to work as requested.

I need an amendment to the formulas. Did not realize this earlier. Sorry for that.

The data will be alternated on each row (A2…F2, A4… F4, A6…F6 so on)
And the results transposed in cells H2, I2, J2, K2

Is there a formula for this change and to copy across.

A B C D E F G H I J K L M
1 ABC BCD CDE DEF EFG FGH Result 2 -1 -1 -5 9 -1 -1 DEF FGH DEF BCD ABC ABC
3
4 -1 -1 -5 -1 -1 9
5
6 -1 -1 -1 5 -1 -1
7
8 -2 8 -6 -4 -2 -2
9
10 6 -1 -1 -1 -1 -2
11
12 4 -3 -7 -3 -3 -6

Thanks for your time and help

FLDS
Try this...

Book1
ABCDEFGHIJKLM
1ABCBCDCDEDEFEFGFGH_______
2-1-1-59-1-1_DEFFGHDEFBCDABCABC
3_____________
4-1-1-5-1-19_______
5_____________
6-1-1-15-1-1_______
7_____________
8-28-6-4-2-2_______
9_____________
106-1-1-1-1-2_______
11_____________
124-3-7-3-3-6_______
Sheet1

This array formula** entered in H2 and copied across:

=INDEX($A1:$F1,MATCH(TRUE,INDEX($A1:$F12,COLUMNS($H2:H2)*2,0)>0,0))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
A small modification:

=OFFSET($A1,,MIN(IF(OFFSET($A$2:$F$2,2*(COLUMNS($H$1:H1)-1),)>0,COLUMN($A$2:$F$2)-COLUMN($A$2)+1))-1)

Markmzz
 
Upvote 0
Mark,

Thank you so much for the formula.
This worked out the way I wanted.

FLDS
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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