Hi All,
I have a script that searches for the string “City Name” and then displays the name of the city from a Excel file .
The excel file will contain many rows containing the string “City Name” and the name of the city in the next column. Here is the code:
try
tell application "Microsoft Excel"
tell worksheet "Sheet1" of active workbook
set worksheetCells to (value of used range)
set totalRows to length of worksheetCells
end tell
end tell
on error
error "The File is not open."
end try
repeat with i from 1 to totalRows
if item i of worksheetCells contains "City Name" then
set nameofCity to (item 2 of (item i of worksheetCells)) as text
display dialog nameofCity
end if
end repeat
This works fine. But sometimes the excel file contains hidden rows that contain the string “City Name”. I want to exclude the results of the hidden rows. How can I achieve this? I know I can delete the hidden rows