Copy second of two cells containing the same text string

dart17

New Member
Joined
Jul 18, 2018
Messages
9
Good morning, I wonder which command I should employ to copy -from column "L"- the first, and then separately the second, of two cells containing the same text string "Cboe CXE". Thank you.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Paste it in another column. The point is that I don't know how to select separately two cells containing the same text string. By using { For Each Cell In Range("L:L")If Cell.Value = "Cboe CXE" Then } it selects only the second cell. What should I do to get the first? And what if I have more than 2 cells with the same string in the same column?
Thank you.
 
Upvote 0
Hi & welcome to MrExcel.
Is this what you're after
Code:
Sub FindCopy()
   Dim Rng As Range
   Dim Fnd As Range
   Dim i As Long, Qty As Long
   
   Set Fnd = Range("L1")
   Qty = Evaluate("countif(L:L,""*Cboe CXE*"")")
   For i = 1 To Qty
      Set Fnd = Range("L:L").find("Cboe CXE", Fnd, , xlPart, , , False, , False)
      If Rng Is Nothing Then Set Rng = Fnd Else Set Rng = Union(Rng, Fnd)
   Next i
   Rng.Copy Range("M1")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top