Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find last column with data
Hi Experts
I am trying to find the last column with data in my sheet. I tried thi code, but it is giving me errors. Do you have any ideas what I'm doin wrong? lastcol = Cells(Columns.Count, "2").End(xlLeft).Column Kind Regard -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find last column with data
Hi Poppy,
lastcol = Cells(Columns.Count, "2").End(xlLeft).Column If you use a numeric column reference, drop the quotes. The Cells syntaax should be: Cells(row, column) To find the last populated cell in row 2, try amending your code to: Set lastcol = Cells(2, Columns.Count).End(xlToLeft) To return the number of the find the last populated column in row 2, try: Cells(2, Columns.Count).End(xlToLeft).Column To find the last populated column on the worksheet, try the following function: Function LastCol(sh As Worksheet) On Error Resume Next LastCol = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column On Error GoTo 0 End Function --- Regards, Norman "poppy " wrote in message ... Hi Experts I am trying to find the last column with data in my sheet. I tried this code, but it is giving me errors. Do you have any ideas what I'm doing wrong? lastcol = Cells(Columns.Count, "2").End(xlLeft).Column Kind Regards --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find last column with data
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
FInd common data in one column then add number in adjacent column | Excel Worksheet Functions | |||
FIND COLUMN DATA | Excel Discussion (Misc queries) | |||
Find last column with data? | Excel Discussion (Misc queries) | |||
compare data in column A with column B to find duplicates | Excel Discussion (Misc queries) | |||
find rows for unique data in 1 column and different data in other. | Excel Discussion (Misc queries) |