Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default find last column with data

I have a file that at times will have various number of columns. How do I
find the last column with data. All rows will have data in the same columns.
I am starting at A2
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default find last column with data

hi
try somedthing like this......
Sub findcol()
Dim c As Long
c = Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox "The Last column is " & Cells(1, c).Address
'Cells(1, c).Select 'optional
End Sub

regards
FSt1
"thomas donino" wrote:

I have a file that at times will have various number of columns. How do I
find the last column with data. All rows will have data in the same columns.
I am starting at A2

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default find last column with data

here's a solution from rick rothstein:

LastUsedRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious).Row

LastUsedCol = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlColumns, _
SearchDirection:=xlPrevious).Column
--


Gary Keramidas
Excel 2003


"FSt1" wrote in message
...
hi
try somedthing like this......
Sub findcol()
Dim c As Long
c = Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox "The Last column is " & Cells(1, c).Address
'Cells(1, c).Select 'optional
End Sub

regards
FSt1
"thomas donino" wrote:

I have a file that at times will have various number of columns. How do I
find the last column with data. All rows will have data in the same columns.
I am starting at A2


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FInd common data in one column then add number in adjacent column JT Excel Worksheet Functions 3 December 18th 09 10:20 PM
compare data in column A with column B to find duplicates George Excel Discussion (Misc queries) 8 February 6th 09 03:53 PM
find data in one column and use data in the next column over Exce charles Excel Programming 2 May 6th 05 01:54 PM
find rows for unique data in 1 column and different data in other. Dot Majewski Excel Discussion (Misc queries) 1 January 21st 05 12:23 AM
Find data in Column D, add L in Column A juan Excel Programming 7 September 28th 04 11:32 PM


All times are GMT +1. The time now is 01:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"