LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Find last used column

Give that code I posted a try. The function returns the column number of the
last column with data in it. You can specify a worksheet or not when you use
the function...
--
HTH...

Jim Thomlinson


"Bryan Brassell" wrote:

Really what I need is the first blank column on a particular worksheet. I
need to paste in a colum of numbers representing completed work. The next
time a batch is run, I need to paste that set of numbers on the same sheet,
in the next column, and so on...

--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141


"Jim Thomlinson" wrote:

By last column I assume you mean the last column with a value in it
anywhere??? Try this...

Public Sub test()
Cells(1, LastColumn() + 1).Select
End Sub

Public Function LastColumn(Optional wks As Worksheet) As Integer
If wks Is Nothing Then Set wks = ActiveSheet
LastColumn = wks.Cells.Find(What:="*", _
After:=wks.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
End Function
--
HTH...

Jim Thomlinson


"Bryan Brassell" wrote:

I am using the following to try to identify the last used column and then
select the top cell of the first empty column after the last used:

myRange = ActiveSheet.UsedRange
NewColumn = (myRange.Columns(myRange.Columns.Count).Column) + 1
ActiveSheet.Cells(1, NewColumn).Select

Can anyone tell me what I am doing wrong? This is not working. The portion
in () in the second line I copied from the help file, but do not understand.
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141

 
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 last row value in column when using MATCH to find column Bouce Excel Worksheet Functions 6 February 6th 08 10:16 PM
Find something in column a then find if column B matches criteria Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 8 November 28th 07 09:40 PM
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM


All times are GMT +1. The time now is 04:08 PM.

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

About Us

"It's about Microsoft Excel"