Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Finding the next cell with specific data in them


  • Please log in to reply
1 reply to this topic
JDMcDowall55
  • Members
  • 4 posts
  • Last active: Aug 08 2015 12:42 AM
  • Joined: 30 Aug 2014

Find the first one is easy

 

xl.Range("A:A").Find(idd).row

 

return the row in with the contents of iDD was found.

How do I find the next row, and the next...



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Example of using the .findnext() method

FullWBname = ____.xlsx ; enter full workbook name here
 
ComObjError(false)
Sheet := ComObjGet(FullWBname).ActiveSheet
ComObjError(true)
 
if Not Sheet 
{
        MsgBox, Could not access workbook
        ExitApp
}
 
InputBox, val, Enter Value to Find:, , , 200, 100
if Not Errorlevel
    if cell := Sheet.UsedRange.Find(val)
        while (cell.Address != firstAddress)
        {
            if (A_index = 1)
                firstAddress := cell.Address
            column := cell.column
            row := cell.row
            MsgBox, % "found " val " in call at `nrow:" Row "`ncol: " column
            cell := Sheet.UsedRange.FindNext(cell)
        }
Sheet := ""
msgbox done!
return

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About