View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bryan Brassell Bryan Brassell is offline
external usenet poster
 
Posts: 8
Default Find last used column

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