Copy Cells Containing Specific Text

jawill40

New Member
Joined
May 13, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'm attempting to copy all cells within a sheet in excel that contain specific text and then paste the copied text into a new sheet. However, I have no VBA knowledge and have so far attempted to use other posts here to accomplish my goal with no luck. It would be awesome if the macro asked what text I was looking for but if it cannot that is fine too, I wont be picky.

My issue I have is that I'm looking for a cell that contains "Photoeye": (including the " "). I have an unknown length of A-rows to search through as well, sometimes is several thousand rows, other times it is around 500.
The VBA code I am currently using is as follows, again I didnt make that code as it is from another post but I cannot seem to get it to work when looking for "Photoeye":
VBA Code:
Sub PHOTOEYE_1()

Dim c As Range
Dim Source As Worksheet
Dim Target As Worksheet
Dim Target1 As Worksheet

Set Source = ActiveWorkbook.Worksheets("Sheet1")

For Each c In Source.Range("A1:A99999" & Source.Cells(Rows.Count, 1).End(xlUp).Row)
   If c = ""Photoeye:"" Then
      c.EntireRow.Copy
      Target.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
   ElseIf c = "Outros" Then
      c.EntireRow.Copy
      Target1.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
   End If
Next c
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

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