Excel VBA not finding the cell wanted

I'm trying to create a macro that retrieves a data according to a search, for example, retrieving the adjacent cell of the one that contains "Date", but somehow excel doesn't match the result I'm looking for, I don't know if it's because that cell it's password protected. Here's my code:

SummarySheet.Range("C" & NRow).Value = WorkBk.Worksheets(2).Cells.Find("Fecha de ", After:=Range("I110")).Offset(0, 0)

And even when I tell excel it looks after I110, the first result is on Cell AU55.. (The offset 0,0 is intentional to see what is it finding)

Can Anyone Help.

Upvotes: 0

Views: 48

Answers (1)

user3598756
user3598756

Reputation: 29421

try

With WorkBk.Worksheets(2)
    SummarySheet.Range("C" & NRow).Value = .Cells.Find("Fecha de ", After:=.Range("I110"), LookIn:=xlValues, lookat:=xlWhole, matchacse:=False).Offset(0, 0)
End With

and have:

  • Range("I110") belong to the same workbook and worksheet of the Cells you're searching through

  • all relevant Find() (LookAt, LookIn, ..) arguments explicitly specified, otherwise they would be assumed with their last setting even from Excel UI

Upvotes: 2

Related Questions