Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find in Excel

Status
Not open for further replies.

AliThePro

Mechanical
Jan 13, 2005
57
I cannot fiqure Out while find fails for one particular data. The line of the code is:
Set curRange = Sheets("Appendix B").Columns("A:A").Find(sIFRAM(iIndex))

The curRange returned for one of the items (iIndex = 210)is Nothing, it works fine for other data in sIFRAM array. I copied the value of sIFRAM(iIndex) from the immediate window and put it in find dialog box in Excel. It finds the data, I checked the spelling few times, it seems OK, any idea why this might be happening?

Thanks,
 
Replies continue below

Recommended for you

I found what the problem is. In Excel trailing space characters are apparanltly ignored if you search for it using the Find ... dialog box. But if you are in VBA, Find fails if you have trailing spaces in your search string and no trailing spaces in the target cell in the search range. Funny! does anybody know how to strip the spaces from string data type in VBA?

Thanks
 
Use the following function to strip both leading and trailing spaces from a string:
Code:
Trim()


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor