PDA

View Full Version : Subract last cell from above



Emoncada
02-08-2013, 12:54 PM
I have a form that I need to populate a Label or Txtbox with the following

I need to be able to find the lastrow cell in ("D") and then subtract that value from the cell above it.

Example if last cell with data in Column D is "D10" then form

textbox = D10-D9

How can I do this?

p45cal
02-08-2013, 02:41 PM
I need to be able to find the lastrow cell in ("D")Set x = Cells(Rows.Count, "D").End(xlUp)



and then subtract that value from the cell above it.TextBox = x.Offset(-1).Value - x.Value



Example if last cell with data in Column D is "D10" then form
textbox = D10-D9that's different:
TextBox = x.Value - x.Offset(-1).Value