mathsbeauty
Board Regular
- Joined
- Apr 23, 2011
- Messages
- 89
The large text is imported from clipboard. I want to have a replace function in excel vba similar to replace function in ms word with the option find "whole words only". The replace function in VBA or worksheet function substitute is of no use. Here is what I am trying to do:
This replaces 101 to 102 but also 1010 to 1020. I just want to replace with exact match (that is just want to replace 101 by 102 but not 1010 to 1020). How can I have excel vba function to achieve this?
Code:
Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
DataObj.GetFromClipboard
Text = DataObj.GetText(1)
NewText = replace(Text, "101", "102")
This replaces 101 to 102 but also 1010 to 1020. I just want to replace with exact match (that is just want to replace 101 by 102 but not 1010 to 1020). How can I have excel vba function to achieve this?
Last edited: