View Single Post
 
Old 08-18-2011, 09:12 AM
Catalin.B Catalin.B is offline Windows Vista Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

maybe i am missing something, the macro works ...and is searching for the last row in column A which is not empty and subtracts it from the cell A2.
use an macro error handler in your macro: (you may copy on your code the red line)
this error handler just ignores errors, but if there are still problems, we will use another one, if necessary...


Sub datesubs()
Dim lastrow As Long
Please keep in mind that the code works only when you enter data in any cell in this worksheet, not when you copy cells or expanding tables

With Sheets("Sheet1")
On Error Resume Next
lastrow = Range("A" & Rows.Count).End(xlUp).Row
Cells(2, 1).Value = Cells(lastrow, 1).Value - Cells(4, 1).Value

End With
End Sub
Reply With Quote