我需要一个VBA代码来搜索可能在电子表格中出现多次但字体大小不同的字符串。
- 首先根据特定字体大小查找字符串(例如:" AABBCCC123",字体11)
- 将字符添加到字符串末尾(B222)
我们的想法是创建一个唯一的ID
由于
答案 0 :(得分:0)
这个怎么样:
Sub Macro1()
Dim myFontSize As Long
Dim myText As String
Dim myRange, myCell As Range
Set myRange = Worksheets("Test").Range("A1:A10") 'define your lookup Range
myFontSize = 11 'define your lookup Font size
myText = "AABBCCC123" 'define your lookup text
For Each myCell In myRange ' check all cells in your Range
If myCell.Font.Size = myFontSize And myCell.Text = myText Then ' look for your font size and text
myCell.Offset(0, 1).Value = "B222" & myCell.Text ' update a cell to the right by adding B222 before your text
'myCell.Value = "B222" & myCell.Text ' update your cell by adding B222 before your text
End If
Next
End Sub