I am attempting to determine if the cell values in column H (number of rows varies per file) are "Words" or "Words2". The cells that do not contain "Words" or "Words2" are split into separate columns based on a space delimiter while those that do contain "Words" and "Words2" have no change. Currently my code does not separates any cells. I am new to using Dim as Range and InStr and I am not entirely sure if it is most efficient to use them. I have tried multiple variations of the code to no avail, as well. ARGNAME is each cell in column H (or at least that is what I am aiming for).
For example: H1 = "Words" no change, and H2 = "Words I don't care about" splits into H2:L2
Sub WordSplit
Dim lastRow As Long
lastRow = Range("A" & Rows.Count).End(xlUp).Row
Dim SrchRng As Range, ARGNAME As Range
Set SrchRng = Range("H1:H" & lastRow)
For Each ARGNAME In SrchRng
If InStr(1, ARGNAME.Value, "Words") Or InStr(1, ARGNAME.Value, "Words2") < 0 _
Then Columns("H:H").TextToColumns Destination:=Range ("H1"), DataType _
:=xlDelimited, ConsecutiveDelimiter:=True, Space:=True, _
FieldInfo:=Array(Array(1, 1)),TrailingMinusNumbers:=True
End If
Next ARGNAME
End Sub