- Nov 22, 2009
- Office Version
I am trying to find if a string of text contains a specific word and if it does, to enter a word in a cell to the right of the text. Here's my code. For some reason the instring number always comes out to 39. But in this case, for every row that has the word "eCard" in the 5th column I want to show the word "eCard" or something like that. With this code EVERY row I have shows "eCard" even if the word in not present.
Sub Find_Text_In_String() ' ' Find_Text_In_String Macro ' Dim bcol As Integer Dim finalcol As Integer Dim finalrow As Integer Dim banana As Variant bcol = Application.Match("Memo", Range("1:1"), 0) finalcol = Cells(1, Columns.Count).End(xlToLeft).Column finalrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row For counter = finalrow To 2 Step -1 If InStr(Cells(finalrow, bcol).Value, "eCard") > 0 Then Cells(counter, bcol + 4) = "eCard" End If Next counter ' End Sub
Last edited by a moderator: