You are here:

Excel/Return header cell contents based on last entry of a range of cells


I would like a formula that would return the contents of a header cell based on the last entry in a range of cells containing two columns. The formulas I have found so far seem to be able to use only one column. I am using Excel 2007

Example of the spreadsheet:
     A       B       C       D
1   Date     Pmt     Chg     Bal
2   8/21          10.00   10.00
3   8/25          10.00   20.00
4   8/29     10.00          10.00

I would like to use the range of columns B and C to find the last entry and then return either Pmt or Chg. I think this may be a VBA formula, I am not to familiar with VBA so could you please include how to enter the formula?

Any help you can give me will be greatly appreciated.
Thank you


If I understand your situation/requirement, then I don't think you need VBA.  I would use


So I find the row of the last value in column B and compare it to the row of the last value in column C.  If the row in B is greater, then I return "Pmt" else I return "Chg"

is that what you want?

this solution assumes columns B and C only hold the kind of data you show in your example.

If column B or C does not contain at least one number, then the formula will return an Error Value (#N/A).  That could be fixed with


If you wanted to make it more dynamic (so you could change the header in B1 and/or C1


Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 All rights reserved.