Hello.I have two columns of data. The first one has empty cells, the second one is full. What I am trying to do is check if the first (H) column's n-th row is empty or not. If it is, do nothing in the third (J) column (leave it blank or just assign zero). If the cell is not empty, in the third (J) column subtract the first (H) column's value from the second (I) column's. This is how it looks like:H I J1,8166 0,7055475 -1,1110524 0,5334240 0,5795186 1,8545 0,2895624 -1,5649375 0,3019480 1,8814 0,7747401 -1,1066599
When I run the above code, r is taking the entire row. For example, if it is 5th row, in the formula it is showing up as 5:5.
Can you help me out please? Thanks.
Code:
Sub op() Dim r As Integer For r = 4 To Cells(Rows.Count, 7).End(xlUp).Row If Not IsEmpty(Range("H" & r)) Then Range("J" & r).Formula = "=(I&r - H&r)" Else If IsEmpty(Range("H" & r)) Then Range("J" & r) = "" End If Next rEnd Sub
Code:
=(I&4:4 - H&4:4)