Finding position of a particular string containing cell in Excel

时间:2015-06-15 14:48:36

标签: excel vba

I am searching for a string using below code

For x = 2 To lastrow
    If Sheets("sheet1").Cells(x, 3) = TFMODE Then
    .......
    'TFMODE is the string discussed
    'This particular string "TFMODE" is randomly recurring throughout 
    'sheet in column 3.

I need to know position for a particular string in sheet1 Then autofill data which is beneath that string position in sheet2

1 个答案:

答案 0 :(得分:0)

One way:

Sub qwerty()
    lastrow = 10
    For x = 2 To lastrow
        If InStr(Sheets("Sheet1").Cells(x, 3), "TFMODE") > 0 Then
            MsgBox Sheets("Sheet1").Cells(x, 3).Address(0, 0)
        End If
    Next x
End Sub

enter image description here