View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
ShaneDevenshire ShaneDevenshire is offline
external usenet poster
 
Posts: 2,344
Default Identify last non-empty column in a table

Hi Sheeloo,

Much better? Not alway; it depends on what you are doing, so providing a
code solutions may be very helpful for the user. Keep up the good work!

--
Thanks,
Shane Devenshire


"Sheeloo" wrote:

Thanks John for your feedback.

Yes, Shanes solution was much better.
Try this
=INDIRECT("A"&MAX((2:2<"")*COLUMN(2:2)))
if you want to get the heading corresponding to the last filled cell in row
2..
This does not need to be entered with ctrl-shift-enter
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"John" wrote:

Sheeloo, Shanes formula solution worked fine for me so I did not need to go
the somewhat more involved approach using your macro. I think this would have
worked also, but I did not try it. Thx so much, john

"Sheeloo" wrote:

Try

'Sheet1 A1-L1 has headers Jan-12
'Following macro will place the Mon name in Sheet2 Cell A1 till the month
row 2 is filled in Sheet1
Sub findLastMonth()
Dim i As Integer
For i = 1 To 12
If Sheets("Sheet1").Cells(2, i).Value = "" Then
Sheets("Sheet2").Cells(1, 1).Value = _
Sheets("Sheet1").Cells(1, i - 1).Value
Exit Sub
End If
Next i
End Sub
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"John" wrote:

I have a table of monthly data for 2008. Monthly columns are empty until
month end data is available, except for the top row which contains the month
names Jan thru Dec.

How do I write a function to place the Excel Column Letter in a cell to
identify the monthly column having the most recent data. If the top cell in
a column is non-blank, then that column, and all before will complete.

Hope this description is clear. Thx for your help, John