简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM