stevenao13
New Member
- Joined
- Apr 9, 2014
- Messages
- 6
I’m trying to create a macro that will search for certain “keywords” from C9 down to the end of the printable area, since the area grows if new rows are added, or to where there is no more data in the B&C columns (whichever is easier to code). I want the cell in the next column (D) that had a keyword hit in column (C) to pull data from a group I’ve named “Recommendation” on another sheet in the same workbook.
Keywords will change for each “Recommendation”, so I will have to place multiple keywords for each “Recommendation” and will have to do this for all items in the “Recommendation” range. This is why I cannot do a formula, as there are 65 items right now and will continue to grow.
Right now I’m using a pull down menu with Data Validation, but hope I can automate to look for the keywords and add these quicker.
The one I started only pulls the data and place it into column D if column C is empty and cannot figure out why it doesn’t see the TXT as a keyword.
Inspection Findings Sheet
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]#[/TD]
[TD]Workplace[/TD]
[TD]Finding[/TD]
[TD]Recommendation[/TD]
[TD]Risk[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]DFW RTR[/TD]
[TD]Fluorescent lamps not guarded[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]DFW ASR[/TD]
[TD]No lockout tagout procedures[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Recommendations Reference Sheet
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Recommendation[/TD]
[TD]Keyword[/TD]
[/TR]
[TR]
[TD]Install protective guards against accidental contact[/TD]
[TD]lamps, covered[/TD]
[/TR]
[TR]
[TD]Use new LOTO templates[/TD]
[TD]lockout tagout, procedures[/TD]
[/TR]
</tbody>[/TABLE]
My crude coding:
Any help is greatly appreciated. I’ve done minor macros from what I’ve learned on here before and this one is just way above what I know currently or tried searching for days on the fix.
Keywords will change for each “Recommendation”, so I will have to place multiple keywords for each “Recommendation” and will have to do this for all items in the “Recommendation” range. This is why I cannot do a formula, as there are 65 items right now and will continue to grow.
Right now I’m using a pull down menu with Data Validation, but hope I can automate to look for the keywords and add these quicker.
The one I started only pulls the data and place it into column D if column C is empty and cannot figure out why it doesn’t see the TXT as a keyword.
Inspection Findings Sheet
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]#[/TD]
[TD]Workplace[/TD]
[TD]Finding[/TD]
[TD]Recommendation[/TD]
[TD]Risk[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]DFW RTR[/TD]
[TD]Fluorescent lamps not guarded[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]DFW ASR[/TD]
[TD]No lockout tagout procedures[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Recommendations Reference Sheet
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Recommendation[/TD]
[TD]Keyword[/TD]
[/TR]
[TR]
[TD]Install protective guards against accidental contact[/TD]
[TD]lamps, covered[/TD]
[/TR]
[TR]
[TD]Use new LOTO templates[/TD]
[TD]lockout tagout, procedures[/TD]
[/TR]
</tbody>[/TABLE]
My crude coding:
PHP:
Sub Auto_Fill()
Application.ScreenUpdating = False
Dim x As Long
For x = 9 To ActiveSheet.UsedRange.Rows.Count
If Cells(x, 3) = (Txt = "*lamps") Then
Cells(x, 4).Value = ThisWorkbook.Worksheets("Recommendations Reference").Cells(51, 1)
End If
Next x
End Sub
Any help is greatly appreciated. I’ve done minor macros from what I’ve learned on here before and this one is just way above what I know currently or tried searching for days on the fix.