Modification:
NID_nemocnice = OriginalTable.Offset(1, NemocniceCol - 1)
I expected there will be array of two items in rw. But there is "Fakultní nemocnice Plzeň"... I think I should rather use for loop instead for each
My corrected code so far:
For i = 2 To OriginalTable.Rows.Count
' NID_nemocnice.cells(i)
m = Application.Match(OriginalTable.Cells(i, NemocniceCol).Value, Nemocnice.Columns(2), 0)
If IsError(m) Then
MsgBox "Item not found in Nemocnice, please fix the sheet data." ' How to add variable?
Exit Sub
End If
Set NID = Nemocnice.Cells(m, 1)
Set NName = Nemocnice.Cells(m, 2)
OriginalTable.Cells(m, NemocniceCol - 1).Value = NID
' OriginalTable.Cells(m, NemocniceCol).Value = NID ' change this to refer the cells(m,2)
Next i