Need help in VB programming

Hi all!

I’m stuck on a script I’m trying to write for an Excel spreadsheet and it’s in VB (or VBA… ?). This is the section of the script giving me hell:


        For Each i In Content
            ' Get row of i
            iAddress = i.Address
            Row = CInt(FindWord(iAddress, 3, "$"))
            If (Trigger = False) Then
                FirstRow = Row
                Trigger = True
            End If
            ' If row contains the current word being searched...
            If InStr(UCase(i.Value), UCase(FindWord(sSearch, w, ","))) > 0 Then
                ' Insert Row at the top, move this row, delete Old empty row
                Debug.Print ("----Match Found, Moving Up to FirstRow")
                Rows(CStr(FirstRow) & ":" & CStr(FirstRow)).Select
                Selection.Insert Shift:=xlDown
                Rows(CStr(Row + 1) & ":" & CStr(Row + 1)).Select
                Selection.Cut Destination:=Rows(CStr(FirstRow) & ":" & CStr(FirstRow))
                Rows(CStr(Row + 1) & ":" & CStr(Row + 1)).Select
                Selection.Delete Shift:=xlUp
            End If
        Next

OK, first some details:

“For Each i In Content”
Content is the selection of cells by the user. Every other piece of my code is working perfectly even the functions I wrote myself (FindWord). The only problem I have is, that at the end of the code at the last line (the “Next”), for some reason the next cell it goes to in the selection is 2 rows down, not one?.. even stranger: It only goes down two rows when the “If InStr(UCase(i.Value), UCase(FindWord(sSearch, w, “,”))) > 0 Then” is evaluated true. Every other time it only goes down one like it’s meant to…

Basically this is part of a script which searches through cells and moves up ones which contain certain words, specified by the user.

Any help would be GREATLY appreciate, this is actually a script I have to write for the place I’m working at… I started learning VB only 2 days ago when they told me this script had to be written in VB.

Basically I need it to only go one line down, not 2. Anyone know why it would be doing this, or how to stop it?

PS: I tried taking the (Row + 1) out of the lines of code in the If section… didn’t fix it, infact it broke the script altogether.