Hi,

Small question: I have a simple Excel file and I'm trying to write a
VB Script that will get a string and will search for it in the Excel
file at a certain column. When string was found I would like to know
the right line.
Note: string appears only once in a specific column.

Any suggestions...?
Shai.

Re: VB Script to read Excel file by papou

papou
Wed May 16 04:17:44 CDT 2007

Hi Shai
With the sample code below, the string "String" will be searched in the
workbook "tests16052007.xls" in the activesheet
in range A1 to A50.
Please amend accordingly and note that no Error is handled.

Dim objxl
Set objxl = CreateObject("Excel.Application")
Dim xlwbk
dim Path
Path = "C:\Documents and Settings\papou\Mes documents\Assistance\mpfe\"
Set xlwbk = objxl.Workbooks.Open( Path & "tests16052007.xls")
Z =
objxl.Evaluate("=ADDRESS(ROW(INDEX(A1:A50,MATCH(""String"",A1:A50,0))),1)")
Wscript.Echo "String was found in cell " & z
xlwbk.Close False
objxl.Quit

HTH
Cordially
Pascal


"Shai" <shai.ovadya@gmail.com> a écrit dans le message de news:
1179290745.276941.290740@l77g2000hsb.googlegroups.com...
> Hi,
>
> Small question: I have a simple Excel file and I'm trying to write a
> VB Script that will get a string and will search for it in the Excel
> file at a certain column. When string was found I would like to know
> the right line.
> Note: string appears only once in a specific column.
>
> Any suggestions...?
> Shai.
>