ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   detect column name of last populated data (https://www.excelbanter.com/excel-programming/335406-detect-column-name-last-populated-data.html)

ilyaskazi[_50_]

detect column name of last populated data
 

i need to detect column name showing msgbox of last used range column

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=38980


davidm

detect column name of last populated data
 

Use:

Sub LastColumn_Number()

num = ActiveSheet.UsedRange.Columns.Count
numq = ActiveSheet.UsedRange.Column - 1
MsgBox num + numq

End Su

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=38980


ilyaskazi[_52_]

detect column name of last populated data
 

Good work. but i need column *NAME* and not NUMBER

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=38980


ilyaskazi[_51_]

detect column name of last populated data
 

ok here is the solution...


Code
-------------------
Dim a As string
Dim num, numq, cn

num = ActiveSheet.Usedrange.Columns.count
numq = ActiveSheet.Usedrange.Column - 1
cn = num + numq

Cells(1, cn).Select
a = ActiveCell.Address

MsgBox Left(Right(a, Len(a) - 1), InStr(Right(a, Len(a) - 1), "$") - 1
-------------------


thankyou.

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=38980



All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com