Этот код помогает вам.Он берет последнюю ячейку обоих столбцов B
и D
и вычитает их значение из N1
cell
:
Sub MySub()
Dim lastBRow As Long
Dim lastDRow As Long
lastBRow = Range("B" & Rows.count).End(xlUp).Row
lastDRow = Range("D" & Rows.count).End(xlUp).Row
Range("N1").Value = Range("B" & lastBRow).Value - Range("D" & lastDRow).Value
End Sub