I would like to, if possible, create a VBA macro to search the entire column A for any words that contain the letters RU (case sensitive, if possible). I would then like for it to be able to copy those words and paste them on a new sheet starting on A1, then A2, etc. I know how to set the range, but I don't even know how to begin to write the rest. Any help will be greatly appreciated.
Best Regards.
Consider:
Sub RUthere()
Dim RU As String, N As Long, K As Long, _
s1 As Worksheet, s2 As Worksheet, r As Range, _
v As Variant
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
RU = "RU"
K = 1
N = s1.Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To N
Set r = s1.Cells(i, "A")
v = r.Value
If InStr(1, v, RU) > 0 Then
r.Copy s2.Cells(K, "A")
K = K + 1
End If
Next i
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.