PDA

View Full Version : column name



oleg_v
03-22-2010, 12:59 PM
Hi

i need a macro that outputs me the name of the last filled column according to the row 3 sheet1


thanks

Bob Phillips
03-22-2010, 02:48 PM
What defines the last filled column, do you mean the last one with data?

If so, try this ARRAY formula

=LEFT(ADDRESS(ROW(),MAX(IF(3:3<>"",COLUMN(3:3))),2),FIND("$",ADDRESS(ROW(),COLUMN(),2),1)-1)

oleg_v
03-22-2010, 11:42 PM
hi
yes
the last column with data
can it be done with macro?
i can not use the array formula in my process


thanks

Bob Phillips
03-23-2010, 12:59 AM
Why not? I know some companies restrict scripting, but formulas?

Bob Phillips
03-23-2010, 01:05 AM
BTW, the VBA would be



Dim LastCol As Long

With ActiveCell

LastCol = Cells(.Row, Columns.Count).End(xlToLeft).Column
End With

On Error Resume Next
MsgBox Split(Columns(LastCol).Address(, False), ":")(1)
On Error GoTo 0