View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Last Used Cell in a row??

this is more generic

Option Explicit

Sub test()
Dim lastcol As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox lastcol
End Sub

--


Gary


"Andrius B." wrote in message
...
Hi.
I hope someone could help me this time, too.

I need to find the last used cell (that is, not empty, contains some data) in
a Row and to get the column number, witch contains that cell.

E.G. such rows


person1 | 4556 | | 4564 | | |
person2 | www | | | | dddddd |

So, if I specify a row number 1, the code should return "4", and for the
second row - "6".

I have tried many examples from Internet, but they return either the first
column or number "256"...

Any ideas?