任何人都可以帮助我 excel宏找到一个特定的字符串并将它的PART复制到另一个单元格
我找到了这个宏,但它复制了整个列。我只想要列
中的部分信息Sub Luxation2()
Dim K As Long, r As Range, v As Variant
K = 1
Dim w1 As Worksheet, w2 As Worksheet
Set w1 = Sheets("Sections")
Set w2 = Sheets("retry")
w1.Activate
For Each r In Intersect(Range("B:B"), ActiveSheet.UsedRange)
v = r.Value
If InStr(v, "periode") > 0 Then
r.Copy w2.Cells(K, 1)
K = K + 1
End If
Next r
End Sub
答案 0 :(得分:0)
目前无聊和消磨时间,所以你走了。
Sub Luxation2()
Dim K As Long, r As Range, v As Variant, p As Long, q As Long
K = 1
Dim w1 As Worksheet, w2 As Worksheet
Set w1 = Sheets("Sections")
Set w2 = Sheets("retry")
For Each r In Intersect(w1.Range("B:B"), w1.UsedRange)
v = r.Value
p = InStr(1, v, " - ")
q = InStrRev(v, " - ")
w2.Cells(K, 1) = Mid(v, p + 3, q - p - 3)
K = K + 1
Next r
End Sub
代码做出各种假设。 “Sections”工作表B列中所有使用过的单元格必须采用您在上面评论中指定的“hello - world - today”格式。如果遇到任何空白单元格或不符合该格式的单元格,则会出错。