andreagiugio
New Member
- Joined
- Oct 22, 2015
- Messages
- 30
Hi all,
I put in a oErrors collection all values stored in column A starting from cell A2
Then, for each cells in an other range (that are strings) I need to check if there is a string in the collection that contains that string. Thestring found in Errors collection then will be my new cell.value
For example:
I have cell.value that is string "Fornit*esistente"
In the oErrors collection I have a string that is "Fornitore inesistente".
<tbody>
</tbody>
I put in a oErrors collection all values stored in column A starting from cell A2
Code:
Dim oErrors As New Collection
On Error Resume Next
lastrow_errors = ActiveSheet.UsedRange.Rows.count
For Each cell2 In ActiveWorkbook.Sheets("generale").Range("A2:A" & lastrow_errors)
oErrors.Add cell2.Value, Key:=cell2.Value
Next cell2
Then, for each cells in an other range (that are strings) I need to check if there is a string in the collection that contains that string. Thestring found in Errors collection then will be my new cell.value
Code:
For i = 1 To oErrors.count
If oErrors(i).Contains(cell.Value) Then
cella2 = oErrors(i)
Exit For
End If
Next
cell.Value = cella2
For example:
I have cell.value that is string "Fornit*esistente"
In the oErrors collection I have a string that is "Fornitore inesistente".
Right now I am getting ALWAYS the first string present in Errors collection, that it is "Codice prestazione & non trovato". It is getting always that first string and then go to "Exit For" for each cell. Could you help? Thanks! |
<tbody>
</tbody>