Hello I have a large sheet of data and I need to extract key words from a long thread of data to work out the product type with a single key word. The threads look a bit like this:
/Womenswear/Own Buy/Petites WO/Woven Tops
I have done the first step of this by setting up a sheet with key words to search for and then next to it what work I want placed on my data sheet. Example bellow
'Rules sheet'
A B
Footwear Shoes
Bags Bags
Backpack Bags
Wallet Bags
Hat Hats and Caps
Key word in column A on a sheet called ‘rules’ and the word I want column B on the same sheet.
I then have a code to search ‘Sheet1’ column D to check for key word and then put new key work in column AC
/Womenswear/Own Buy/Petites WO/Woven Tops
I have done the first step of this by setting up a sheet with key words to search for and then next to it what work I want placed on my data sheet. Example bellow
'Rules sheet'
A B
Footwear Shoes
Bags Bags
Backpack Bags
Wallet Bags
Hat Hats and Caps
Key word in column A on a sheet called ‘rules’ and the word I want column B on the same sheet.
I then have a code to search ‘Sheet1’ column D to check for key word and then put new key work in column AC
Code:
[COLOR="#008000"]Sub ListMarkerD()
Dim s1 As Worksheet, s2 As Worksheet
Dim N1 As Long, N2 As Long
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("rules")
N1 = s1.Cells(Rows.Count, "D").End(xlUp).Row
N2 = s2.Cells(Rows.Count, "E").End(xlUp).Row
For i = 2 To N1 ''the 1 is starting from cell 1
v = s1.Cells(i, 4).Value
For j = 2 To N2
If InStr(1, v, s2.Cells(j, 5).Value) > 0
s1.Cells(i, "AC").Value = s2.Cells(j, "F").Value
End If
Next j Next i
End Sub[/COLOR]
[code]
This works fine but now I have some slightly more difficult combinations of key words in different columns in sheet 1 that I need to search by and I am having real problems working out how to do this.
Instead of searching for a single key word and adding the new work in column AC I now need to search for more than one key word in different columns and exclude if there is a third key word.
For example I need to find everything in column D that has the word Hair and everything in column G that has the words Hair Accessory and put the words Hair Accessories in column, however at the same time I also want to exclude any results that have the word Beauty in column G.
I hope that make sense. Any pointers anyone can give me would be really appreciated.
Thanks