Forum Discussion
Trying to use VBA to perform an Automated find and replace function
Hello,
I am having trouble performing a find and replace with VBA. I am using a piece of code I modified for my work book. However I am running into a "compile error Expected list separator or )" . I do not see the issue at this time and I have been trying to research the root causes behind the message but I do not see in the code why it would cause it at this time. I am using Office 365.
The purpose of my code is to look at Daily Pick Data worksheet with a column that has some old user codes in it and replace them using a table on a Click USER Ref worksheet that has the new user code.
I am trying to automate this process because I will be pulling this data daily and do not want to find and replace manually or create extra columns just to use the lookup fx(s).
The code is the following:
Sub multiFindandReplace()
Dim myList
Dim myRange
Set myList = Sheets(“Click USER Ref”).Range(“A2:B24”)
Set myRange = Sheets(“Daily Pick Data”).Range(“D5:D515”)
For Each cel In myList.Columns(1).Cells
myRange.Replace What:=cel.Value, Replacement:=cel.Offset(0, 1).Value, LookAt:=xlWhole
Next cel
End Sub
Thank you.
6 Replies
- Subodh_Tiwari_sktneerSilver Contributor
How about uploading a sample file with some dummy data in both the worksheets along with the logic you are trying to replace data. That would help to suggest a working solution considering your existing data.
- IshmaleCopper Contributor
For some reason I can Not upload a file or at least do not see an option to upload a file.
I would like to search the user code column in the "Daily Pick Data" sheet and then using the list in the "Click USER Ref" sheet find the old code and replace the "Daily Pick Data" cell with the new user code from the table on "Click USER Ref".
Sorry for not being able to post the upload the file.
- IshmaleCopper Contributor