[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

find whole words in excel

Meena Chidambaram

2/28/2008 6:39:00 AM

I am trying to locate a column name in excel and i am using the "find"
method. But it seems to be doing a partial match (instead of whole word
match).
I have two columns in my excel "ParentOrgId" and "OrgId" , when i search
for "OrgId" it returns the "ParentOrgId" . How can i make it do a whole
word match so that it returns "OrgId".

The snippet of code used is given below

equire 'win32ole'

excel = WIN32OLE.connect("excel.application")
excel.visible = TRUE
wbook=excel.Workbooks.open("D:/test.xls")
wsheet=wbook.Worksheets("OrgInfo")
rFoundCell = wsheet.Range("A1:IV1").Find('OrgId')
puts rFoundCell.value
--
Posted via http://www.ruby-....

1 Answer

Raffaele Tesi

2/28/2008 12:54:00 PM

0

the .find method signature has more then one parameter (all optional).
Look at this url for some example: http://www.rondebruin.n...


A snippet:

With Sheets("Sheet1").Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
--
Posted via http://www.ruby-....