Find the below code. Attached sample excel file with this mail.

Set objConnectionFile = CreateObject("ADODB.Connection")
objConnectionFile.ConnectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=<PATH OF THE EXCEL FILE > ;Extended Properties=Excel 12.0;Persist
Security Info=False"
objConnectionFile.Open

Msgbox GetTheValueofPerviousColoumn("India")


Function GetTheValueofPerviousColoumn(strColoumnValue)
    set objRecordSet=objConnectionFile.Execute("Select * from [Sheet1$]
where  [Country]='"&strColoumnValue&"'")

GetTheValueofPerviousColoumn= objRecordSet.Fields(0).Value
End Function

Set objRecordSet= nothing
Set objConnectionFile= nothing

*Please let me know if you have any question.*

*Regards,*

*Hokrani*


On Sun, Mar 30, 2014 at 8:31 AM, george <[email protected]> wrote:

> Hi Guys,
>
> Please advise what to do in this case.
> The following script opens my excel workbook, searches the string and
> highlights the value:
> ______________________________________________________
>
> Set myxl = createobject("excel.application")
> myxl.Workbooks.Open "C:\book1.xlsx"
> myxl.Application.Visible = true
> set mysheet = myxl.ActiveWorkbook.Worksheets("Sheet1")
>
> With mysheet.UsedRange
>
>             For each search_data in mysheet.UsedRange
>
>                          If search_data="11" then
>
>                 search_data.Interior.ColorIndex = 40
>
>                         End If
>            Next
> End With
>
> 'Save the Workbook
> 'myxl.ActiveWorkbook.Save
> 'Close the Workbook
> myxl.ActiveWorkbook.Close
> 'Close Excel
> myxl.Application.Quit
> Set mysheet =nothing
> Set myxl = nothing
>
> _________________________________
>
>
> This works, but I want the value from next column:
>
> xlsx example:
>
> A                     B
>
> 01                 usa
> 02                 canada
>
>
> I would like to highlight and *maybe Print *"usa" as versus highlighting
> 01 only.
>
> please send me the code
>
> thanks in advance
>
>
>  --
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "QTP - HP Quick Test Professional - Automated Software Testing" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Hoks

-- 
-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

--- 
You received this message because you are subscribed to the Google Groups "QTP 
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: testdata.xls
Description: MS-Excel spreadsheet

Reply via email to