0
Dim coname, WHAT_TO_FIND As String
    Dim i As Integer
    totalRow = Application.CountA(Range("c:c")) - 1
    i = 2
    While i <= totalRow
    coname = Sheet20.Cells(i, "A") 
    i = i + 1
    WHAT_TO_FIND = coname
    sheets("Sheet21").Select 
    Set ws = ActiveSheet
    Set FoundCell = ws.Range("D:D").Find(what:=WHAT_TO_FIND, lookat:=xlWhole)

    wend

// in sheet20 I have limited number of comapny names list
// in sheet21 I have the data with n number of company names

Please let me know how to select that particular cell which is found in sheet21.

1 Answers1

1

Try and avoid using .Select INTERESTING READ

However to answer your question, paste this code below

Set FoundCell = ws.Range("D:D").Find(what:=WHAT_TO_FIND, lookat:=xlWhole)
If Not FoundCell Is Nothing Then FoundCell.Select

I would rather use this

Set FoundCell = ws.Range("D:D").Find(what:=WHAT_TO_FIND, lookat:=xlWhole)
If Not FoundCell Is Nothing Then
    With FoundCell
        '
        '~~> Do something
        '
    End With
End If
Community
  • 1
  • 1
Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250