Hello,
I am having some difficulties in achieving the following. I would like the entire contents located in say cell A1 to replace a certain string of text located in another cell, K1. The contents of column A will always be different, with varying lengths of characters and numbers. The text I want to replace in K1 with A1, is always in the same location towards the beginning of the cell wrapped in some formatting html. (11 characters before first word and 4 characters after last)
At first I thought the copy, replace or paste functions would be the ones to use, but after researching, I cannot find anything where the replacement is a specific string of text within a cell. Unless, I missed it in my searching. String functions don’t seem to be my solution either,as shown in my attempt at one below. Any help is greatly appreciated. Thanks in advance!
Sub replace()
Dim myCell As Range
Dim myStringToReplace As String
Dim myReplacementString As String
Set myCell =ThisWorkbook.Worksheets("Items CSV Test").Range("K1")
myStringToReplace = "Make Model Item"
myReplacementString = "ABC 123Controller"
myCell.Value =Replace(Expression:=myCell.Value, Find:=myStringToReplace,Replace:=myReplacementString)
End Sub
I am having some difficulties in achieving the following. I would like the entire contents located in say cell A1 to replace a certain string of text located in another cell, K1. The contents of column A will always be different, with varying lengths of characters and numbers. The text I want to replace in K1 with A1, is always in the same location towards the beginning of the cell wrapped in some formatting html. (11 characters before first word and 4 characters after last)
At first I thought the copy, replace or paste functions would be the ones to use, but after researching, I cannot find anything where the replacement is a specific string of text within a cell. Unless, I missed it in my searching. String functions don’t seem to be my solution either,as shown in my attempt at one below. Any help is greatly appreciated. Thanks in advance!
Sub replace()
Dim myCell As Range
Dim myStringToReplace As String
Dim myReplacementString As String
Set myCell =ThisWorkbook.Worksheets("Items CSV Test").Range("K1")
myStringToReplace = "Make Model Item"
myReplacementString = "ABC 123Controller"
myCell.Value =Replace(Expression:=myCell.Value, Find:=myStringToReplace,Replace:=myReplacementString)
End Sub