Hi all,
I have two worksheets in different workbook, and when some conditions are satisfied, I will substract the value of Range("J" & cell.Row) in desSheet by the value of Range("J" & cell.Row) in Pr worksheet.
The variable "cell" indicates a selected cell.
The full version of code is as below:
Now I receive an error message "Type mismatch" over the line:
Could you pls help me to find out the bug and solve this problem?
Thank you very much!
yours sincerely,
lolo^^
I have two worksheets in different workbook, and when some conditions are satisfied, I will substract the value of Range("J" & cell.Row) in desSheet by the value of Range("J" & cell.Row) in Pr worksheet.
The variable "cell" indicates a selected cell.
The full version of code is as below:
Code:
With desSheet
For Each cell In Range("F4", Range("F" & Rows.count).End(xlUp))
For i = 1 To 22
If cell.Value = Trans_Part(i) Then
'check whether quantity is the same
If .Range("J" & cell.Row).Value = Pr.Range("I" & i).Value Then
'delete the entire row
.Range("A" & cell.Row & ":N" & cell.Row).Delete
Else
'substract current quantity by the amount this row just submitted
.Range("J" & cell.Row).Value = CInt(.Range("J" & cell.Row).Value) - CInt(Pr.Range("I" & i).Value)
End If
End If
Next i
Next cell
End With
Now I receive an error message "Type mismatch" over the line:
Code:
.Range("J" & cell.Row).Value = CInt(.Range("J" & cell.Row).Value) - CInt(Pr.Range("I" & i).Value)
Could you pls help me to find out the bug and solve this problem?
Thank you very much!
yours sincerely,
lolo^^
Last edited: