VBA: Search for keywords in data strings and perform actions with that data

iHuman

New Member
Joined
Aug 21, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello

I have data that I manually scrape every day. This data needs to be organized into different sheets.
I have a workbook with different sheets.
The source worksheet of the data is "Today's Work"
The target worksheet is "IQ Eligible"

In Today's Work, column A contains information in the following format: random_text_IQ-eligible , where the random text changes for each cell.
The important thing to know is that not all the data will end in "IQ-eligible".
The VBA macro needs to be able to find and isolate the rows (A:C) that contain "IQ-eligible" and then copy them over to worksheet "IQ Work"
How would we go about this?

I have some VBA code that is being used for a different purpose, but some of it can be recycled into building this new macro.


VBA Code:
Sub Test()

Dim c As Range
Dim d As Long
Dim Source As Worksheet
Dim Target As Worksheet

Set Source = ActiveWorkbook.Worksheets("Today's Work")
Set Target = ActiveWorkbook.Worksheets("Bin Work")

For Each c In Source.Range("C1:C" & Source.Cells(Rows.Count, 1).End(xlUp).Row)
   If c = "Bin" Then
        Source.Range("A" & c.Row & ":C" & c.Row).Copy
        Target.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
        Source.Range("A" & c.Row & ":C" & c.Row).ClearContents
   End If
Next c

For d = Source.Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
    If Application.WorksheetFunction.CountA(Source.Range("A" & d & ":" & "C" & d)) = 0 Then
        Source.Range("A" & d & ":C" & d).Delete Shift:=xlUp
    End If
Next d

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
*****Correction******
copy them over to worksheet "IQ Work"
Needs to be worksheet "IQ Eligible"

Apologies!
 
Upvote 0
Closing this thread.
I was able to figure it out on my own, using the VBA "like" operator and asterisks.
 
Upvote 0
Good to hear you got the solution.
If you would like to post the actual solution then it is perfectly fine to mark your post as the solution to help future readers. Otherwise, please do not mark a post that doesn't contain a solution.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,970
Members
449,095
Latest member
Mr Hughes

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