Jump to content

Cells.Find excel method


 Share

Recommended Posts

Hello all,

I want to search for a string (inside a excel sheet)using the method Cells.Find

Looking the VBA code I found this:

Cells.Find(What:="text", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
        .Activate

How this code can to be traduced in AutoIT?

Tanks

Gianluca

Link to comment
Share on other sites

Traduced: Humiliated or disgraced by malicious and false statements

??? :) ???

Assuming you meant "Translated", try:

.Cells.Find('What:="text", After:=' & $ActiveCell & ', LookIn:=' & $xlValues & ', LookAt:=' & $xlPart & ', SearchOrder:=' & $xlByRows & ', SearchDirection:=' & $xlNext & ', MatchCase:=' & False).Activate

You have to track down the values for the variables (like $xlValues) if they are not already declared in Excel.au3, but I think other examples of this have been posted.

:(

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Traduced: Humiliated or disgraced by malicious and false statements

Traduced... I'm sorry for my poor english! Yes I meant Translated...

Thanks to you, the following code seems to work, but still remains an odd behaviour.

If the same string are written in more cells, the code jump directly on the last cell, so it find only the last occurence.

This is strange; i want search for the next cell (that contains the string) after the active cell, not for the last cell!

Any idea? Thanks a lot again.

$oExcel = _ExcelBookOpen($ExcelFile)
$oExcel.Range("A1").Activate
$sFindWhat = "text"
$oExcel.Cells.Find($sFindWhat, $oExcel.ActiveCell, $xlValue, $xlPart, $xlByRows, $xlNext, False).Activate
MsgBox (0,"",$oExcel.ActiveCells.Address)
Link to comment
Share on other sites

I'm pretty sure it's the "After:=ActiveCell" part, which doesn't work as expected. Don't have Excel here, so I can't test anything. Sorry.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Assuming you meant "Translated", try:

.Cells.Find('What:="text", After:=' & $ActiveCell & ', LookIn:=' & $xlValues & ', LookAt:=' & $xlPart & ', SearchOrder:=' & $xlByRows & ', SearchDirection:=' & $xlNext & ', MatchCase:=' & False).Activate

Thanks for this tip, I've been looking for ages for a way to pass stuff to VBA using the Key:=Value syntax.

I've been using this, which is a pain to read:

.Find("", Default, Default, $xlWhole)

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Link to comment
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
 Share

  • Recently Browsing   1 member

×
×
  • Create New...