Jump to content

find the row number of excel sheets with two particular column values

Recommended Posts

I have a sheet it has 5 columns and more than 1000 rows. I have to identify a row by its 1st and 5th column and get the values of 2,3 and 4 column values in that particular row. I have used For loop but this is taking more time for identifying the row. Please help in resolving this problem.

Link to post
Share on other sites
  • Moderators

You have very nicely defined what you want, however you have not shown what you have tried to accomplish on your own. Please start with looking at the Excel functions in the help file. There are a couple of ways you could tackle the problem. For the simplest, try something like this:

   Look at _Excel_Open() and _Excel_BookOpen() to open the workbook in question. 

   Look at _Excel_RangeRead, read the range into an array and then parse through the array looking for your values.

 I'll leave you to tweak this to your needs...


_excel_bookopen(<path to book>)
$aRange = _excel_rangeread(workbook, worksheet, range)
    For $i = 0 to ubound($arange) - 1
        If $arange column 1 = x and $arange column 5 = y Then
           return $arange columns 2, 3 and 4


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...