Hi everyone!
So I was able to write a script that is attached to a button that would search for a specific variable in one sheet and then pull that data on the identified row to another sheet.
I receive a Run-time error "13": Type mismatch but the code still performs the task anyways.
Do I need to worry about this run-time error since it is still working? When I do the debug it shows that the issue involves my 'If Worksheets' line (in bold red in the below code).
This is the code:
Sub CaseAssignPathSH()
Dim lastrom As Long, erow As Long
'to check the last filled line on sheet neamed merge
lastrow = Worksheets("Merge").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("Merge").Cells(i, 20).Value = "SH" Then
Worksheets("Merge").Cells(i, 16).Copy
erow = Worksheets("PATH CASES").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Merge").Paste Destination:=Worksheets("PATH CASES").Cells(erow + 1, 1)
Worksheets("Merge").Cells(i, 17).Copy
Worksheets("Merge").Paste Destination:=Worksheets("PATH CASES").Cells(erow + 1, 2)
Worksheets("Merge").Cells(i, 18).Copy
Worksheets("Merge").Paste Destination:=Worksheets("PATH CASES").Cells(erow + 1, 3)
End If
So I was able to write a script that is attached to a button that would search for a specific variable in one sheet and then pull that data on the identified row to another sheet.
I receive a Run-time error "13": Type mismatch but the code still performs the task anyways.
Do I need to worry about this run-time error since it is still working? When I do the debug it shows that the issue involves my 'If Worksheets' line (in bold red in the below code).
This is the code:
Sub CaseAssignPathSH()
Dim lastrom As Long, erow As Long
'to check the last filled line on sheet neamed merge
lastrow = Worksheets("Merge").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("Merge").Cells(i, 20).Value = "SH" Then
Worksheets("Merge").Cells(i, 16).Copy
erow = Worksheets("PATH CASES").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Merge").Paste Destination:=Worksheets("PATH CASES").Cells(erow + 1, 1)
Worksheets("Merge").Cells(i, 17).Copy
Worksheets("Merge").Paste Destination:=Worksheets("PATH CASES").Cells(erow + 1, 2)
Worksheets("Merge").Cells(i, 18).Copy
Worksheets("Merge").Paste Destination:=Worksheets("PATH CASES").Cells(erow + 1, 3)
End If