作者:菜鸟自学编程 | 来源:互联网 | 2023-05-17 13:43
IneedtosearchandtoreplaceaspecificpartofastringinanExcelsheet.我需要在Excel工作表中搜索并替换字符串
I need to search and to replace a specific part of a string in an Excel sheet.
我需要在Excel工作表中搜索并替换字符串的特定部分。
Here is my code and I don't know how I can exactly search this part in each Cell.value
.
这是我的代码,我不知道如何在每个Cell.value中精确搜索这个部分。
my_new_string = "abc"
For each objSheet1 in objworkbook2.sheets
If objSheet1.Name = "Name1" Then
LastRow = objsheet1.UsedRange.Rows.Count + objsheet1.UsedRange.Row - 1
For i = 1 To LastRow Step 1
For j = 1 To 15 Step 1
If objExcel1.Cells(i, j).value = "xyz" Then 'Here I have to check if the Cell value contains xyz and to replace it by **my_new_string**
End if
Next
Next
End If
Next
Any help please ?
有什么帮助吗?
2 个解决方案