Last active
June 9, 2017 16:01
-
-
Save metzenseifner/c0aeb6975037e89a0350cdd68e3a91a1 to your computer and use it in GitHub Desktop.
Excel Iterate Cell by Cell Both Variants
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Microsoft Excel" | |
set screen updating to false -- optimize performance | |
set range_selected to selection | |
-- setup ref vars for selection | |
set {range_selected_row_index, range_selected_column_index, range_selected_row_count, range_selected_column_count} to {get first row index of selection, get first column index of selection, get count rows of selection, get count columns of selection} | |
-- go row by row and iterate each column in each row | |
repeat with row_step from range_selected_row_index to range_selected_row_count -- row iteration | |
repeat with column_step from range_selected_column_index to range_selected_column_count -- column iteration | |
set range_this_cell to range (get address row row_step of column column_step of active sheet) of active sheet | |
log range_selected | |
end repeat | |
end repeat | |
-- go column by column and iterate each row in each column | |
repeat with column_step from range_selected_column_index to range_selected_column_count -- column iteration | |
repeat with row_step from range_selected_row_index to range_selected_row_count -- row iteration | |
set range_this_cell to range (get address row row_step of column column_step of active sheet) of active sheet | |
log range_selected | |
end repeat | |
end repeat | |
set screen updating to true -- optimize performance | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment