
Option Explicit
Sub SottraiDUT1()
Dim Nriga As Long, i As Long
Dim DUT1valH As Single, Dut1valI As Single
Nriga = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Nriga
If Trim(Cells(i, "A")) = "DUT1" Then
DUT1valH = Cells(i, "H")
Dut1valI = Cells(i, "I")
Exit For
End If
Next i
For i = 1 To Nriga
Cells(i, "K") = Cells(i, "H") - DUT1valH '''k - H
Cells(i, "L") = Cells(i, "I") - Dut1valI '''L - I
Next i
End Sub
|
Option Explicit
Sub SottraiDUT1()
Dim Nriga As Long, i As Long
Dim DUT1valH As Single, Dut1valI As Single
Nriga = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Nriga
If Trim(Cells(i, "A")) = "DUT1" Then
DUT1valH = Cells(i, "H")
Dut1valI = Cells(i, "I")
Exit For
End If
Next i
For i = 1 To Nriga
If Fix(Cells(i, "H")) <> 0 Then
Cells(i, "K") = (Cells(i, "H") - DUT1valH) / 1000 '''k - H
Else
Cells(i, "K") = ((Cells(i, "H") * 1000) - DUT1valH) / 1000 '''k - H
End If
If Fix(Cells(i, "I")) <> 0 Then
Cells(i, "L") = (Cells(i, "I") - Dut1valI) / 1000 '''L - I
Else
Cells(i, "L") = ((Cells(i, "I") * 1000) - Dut1valI) / 1000 '''L - I
End If
Next i
End Sub
|
Option Explicit
Sub SottraiFoglio2()
Dim Nriga As Long, i As Long
Dim DUT1valH As Single, Dut1valI As Single
Dim VarA1 As Variant
Nriga = Sheets("Foglio1").Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Nriga
VarA1 = Sheets("Foglio1").Cells(i, "A")
If Trim(VarA1) = "DUT1" Then
DUT1valH = Sheets("Foglio1").Cells(i, "H")
Dut1valI = Sheets("Foglio1").Cells(i, "I")
Exit For
End If
Next i
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Fix(Cells(i, "H")) <> 0 Then
Cells(i, "K") = (Cells(i, "H") - DUT1valH) / 1000 '''k - H
Else
Cells(i, "K") = ((Cells(i, "H") * 1000) - DUT1valH) / 1000 '''k - H
End If
If Fix(Cells(i, "I")) <> 0 Then
Cells(i, "L") = (Cells(i, "I") - Dut1valI) / 1000 '''L - I
Else
Cells(i, "L") = ((Cells(i, "I") * 1000) - Dut1valI) / 1000 '''L - I
End If
Next i
End Sub
|
