View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Marcotte A Marcotte A is offline
external usenet poster
 
Posts: 66
Default Find last populated cell in a row.

LastRow = CSVData.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row

I use that code to find the last row of data in a column (column A in this
case). It should be fairly easy to modify to find the last column of data in
a row..... but I can't do it. The following is slightly different, but does
work.

Sub test()
Dim lastcolumn As integer

lastcolumn = ThisWorkbook.Sheets(1).Cells(16,
Columns.Count).SpecialCells(xlCellTypeLastCell)
MsgBox lastcolumn
End Sub



"RJG" wrote:

I need to keep a summary of our latest prices plus the previous price ,
so on sheet1 cell C5 is the previous price while cell D5 is the current
price.

I want these prices to update automatically whenever a price change
occures. Each time a price change occures the new price is added to row
16, currently the last price is X16 while the previous price is W16.

How do I get cell D5 to lookup the last item in row 16 and C5 to find
the last but one item in row 16.

With thanks

Bob