marreco
Well-known Member
- Joined
- Jan 1, 2011
- Messages
- 609
- Office Version
- 2010
- Platform
- Windows
Hi.
I need find a text in column E and F then replace this value using Rng.Offset(, 1).Value
But in column E, I need find any text like "*Cancel*"
Thank you!!
I need find a text in column E and F then replace this value using Rng.Offset(, 1).Value
But in column E, I need find any text like "*Cancel*"
Code:
Sub FindAndReplace()
'I try adapt this code made by Fluff
'https://www.mrexcel.com/forum/excel-questions/1067092-excel-vba-dictionary-replacing-text-strings.html
Dim Rng As Range
Dim Dic As Object
Set Dic = CreateObject("scripting.dictionary")
Dic.Add "Cancel", "1" 'I need lookup [Cancel] value in column E and replace for 1
Dic.Add "X", "1" 'I need lookup [X] value in column F and replace for 1
For Each Rng In Range("E2", Range("E" & Rows.Count).End(xlUp))
If Not (Dic(Rng.Value).Position Like "*Cancel*") Then
Rng.Offset(, 1).Value = Dic(Rng.Value)
End If
Next Rng
End Sub
Thank you!!