help identifying the first and last populated cells in any given row

tbablue

Active Member
Joined
Apr 29, 2007
Messages
475
Office Version
  1. 365
Platform
  1. Windows
In row 2 of sheet 1 ($J$2:$AZ$2) I have some date values (200901,200902,200903,etc) as column headers. Subsequent rows ($J$3:$AZ$100) contain figures pertinent to the associated column headers - not all cells are populated, in fact most are blank. Column 'I' contains a list of names.

A simple Gantt or ECWP; tasks down the side - weeks along the top.

In column A I need a formula that returns the corresponding date value for the first populated cell in the row.

In column B I need a formula that returns the corresponding date value for the last populated cell in the row.

Can anyone help me with a formula for this? I can manufacture a long winded solution - I was hoping somone might know a 'cleaner' way to do this.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
In A3, enter the following array formula:

=INDEX($J3:$AZ3,MATCH(TRUE,$J3:$AZ3<>0,0))

In B3, a second array:

=INDEX($J3:$AZ3,MATCH(2,1/($J3:$AZ3<>"")))

Array formulas are entered by pressing CTRL-SHIFT-ENTER to get the braces { } to appear around the formulas. If you just press ENTER, it will won't work.

After activating the arrays, the formulas can be copied down.
 
Upvote 0
200901 200902 200903 200904 200905 200906 200907 200908
TASK 1
TASK 2 10 10 10 10
TASK 3
TASK 4
TASK 5 15
TASK 6
TASK 7 12 12 12 12 12
TASK 8
TASK 9 5 5 5
TASK 10
TASK 11

excuse the rudimentary table - i'm at work and cant install the HTML tool

consider - the list of tasks is column C. In column A, I need a cute way to look across the rows and return the corresponding column header for the first populated cell in that row. Similarly, in column B I need a cute way to look across the rows and return the corresponding column header for the last populated cell in that row.

Does this help?
 
Upvote 0
The first formula is still an array, but the last one is easier since we can just use a FALSE status on a LARGE number to return the last value.

Excel Workbook
ABCDEFGHIJK
1FirstLastTasks200901200902200903200904200905200906200907200908
2  TASK 1
3200901200904TASK 210101010
4TASK 3
5TASK 4
6200901200901TASK 515
7TASK 6
8200901200905TASK 71212121212
9TASK 8
10200901200903TASK 9555
11TASK 10
12TASK 11
Sheet3


After entering the first two formulas, just copy down.
 
Upvote 0
Or maybe this (no array formula).

Excel Workbook
ABCDEFGHIJK
1FirstLastTasks200901200902200903200904200905200906200907200908
2  TASK 1
3200901200904TASK 210101010
4TASK 3
5TASK 4
6200901200901TASK 515
7TASK 6
8200901200905TASK 71212121212
9TASK 8
10200901200903TASK 9555
11TASK 10
12TASK 11
First& Last
 
Upvote 0

Forum statistics

Threads
1,203,605
Messages
6,056,268
Members
444,853
Latest member
sam69

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