Find last populated cell in a row.
Enter the following UDFs:
Function FTZ1() As Double
Dim i As Integer
FTZ1 = 0
For i = 256 To 1 Step -1
If Cells(16, i).Value = "" Then
Else
FTZ1 = Cells(16, i).Value
Exit For
End If
Next
End Function
--------------------------------------------------------------------------
Function FTZ2() As Double
Dim i As Integer
FTZ2 = 0
For i = 256 To 1 Step -1
If Cells(16, i).Value = "" Then
Else
FTZ2 = Cells(16, i - 1).Value
Exit For
End If
Next
End Function
Then in D5 put =FTZ1() and in C5 put =FTZ2()
--
Gary's Student
"Marcotte A" wrote:
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
|