Hi guys,
New to this. Can you please help me find out why the script show this error? Also is there a way to load the txt file from a google drive location?
The script basically search a column for a set of words in the txt file and highlight any row containing the words. If anyone have a better script for this let me know.
New to this. Can you please help me find out why the script show this error? Also is there a way to load the txt file from a google drive location?
The script basically search a column for a set of words in the txt file and highlight any row containing the words. If anyone have a better script for this let me know.
VBA Code:
Sub lazyLala()
'Variables
Dim wordlist() As String, size As Integer
Dim textFile As String
Dim str As String
'Initializer
textFile = ActiveWorkbook.Path & "/SearchWords.txt"
'Get Length of List
Open textFile For Input As #1
str = Input(LOF(1), 1)
size = Len(str) - Len(Replace(str, vbLf, "")) + 1
Close #1
'Get List
ReDim wordlist(size)
Dim x As Integer
x = 1
Open textFile For Input As #1
Do While Not EOF(1)
Input #1, wordlist(x)
x = x + 1
Loop
Close #1
Range("B2").Select
' Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)
For i = 1 To size
If InStrB(1, ActiveCell.Value, wordlist(i), vbBinaryCompare) <> 0 Then
ActiveCell.EntireRow.Interior.ColorIndex = 36
End If
Next i
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Last edited by a moderator: