Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng 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
Joined
Jan 13, 2005
Messages
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,
 
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

Back
Top