title: AppleScript & Excel: search range for specific value and return alert if found
body: <p>I am an AppleScript newbie, and have started to put together a script to take a spreadsheet and format it for import into another application. It is a monthly donation sheet that doesn't have donor ID's for any of the donors listed on the sheet, so I've assigned a VLOOKUP function to search for donor ID's of known donors in another sheet and assign them in the cells next to the donor's name. All known donors get their ID entered, and unknown donors return an "#N/A". This part of the script works great, and now I need to figure out the way to search for the "#N/A" values in those range of cells and return a "New Donor" display alert if there are any. I have scoured the internet trying to figure out the best way to search a range of cells for an exact value in each of the cells in that range and return an alert if there is one, but have not found anything that I've been able to get to work. Here's what I have:</p>
  
  <pre><code>tell worksheet "Sheet 1" of active workbook
      set value of cell "A5" to "DonorID"
      autofit columns of range "A1:A100"
      set lastRow to ((count of rows of used range of active sheet) - 13)
      set myRange to range ("A6:A" &amp; lastRow) of active sheet
      set formula of myRange to "=VLOOKUP($C$6:$C$90,'[Donor ID.xlsx]Sheet1'!$A$1:$B$60, 2, FALSE)"
      set value of cell "F5" to "Donation Method"
      set myRange2 to range ("F6:F" &amp; lastRow) of active sheet
      set formula of myRange2 to "=IF(D6=\"\",\"Check\", IF(D6=\"CC\",\"Credit Card\", IF(ISNUMBER(SEARCH(\"E\",D6)),\"EFT\",\"#N/A\")))"
      end tell
  </code></pre>
  
  <p>So I need to search the value of each cell in the range from A6 to A of the lastRow (amount of donors changes every month) for the value "#N/A" and if there is one, have an alert displayed saying "New Donor". I've tried this with no success:</p>
  
  <pre><code>  if myRange contains the value "#N/A" then
    display alert "New Donor"
    end if
  </code></pre>
  
  <p>It doesn't pick up the "#N/A" when there is one. I've tried a few other things too, but they were even worse. My lack of AppleScript knowledge is frustrating me, as I'm so close to being done with this script but can't get over this obstacle. Thanks for any feedback!</p>