Here’s an excel script I wrote to copy a vertical group of cells ending in a keyword, and then pasting these cells horizontally on the next page.
The only thing I’d love to add on eventually is a dialog box that pops up at the beginning which asks you what you’d like the delineating keyword to be. For now the keyword is “Map” but of course can be changed to whatever you like. The default number of entires is 80 (this can be changed in the script too)
Eg. (keyword is Map)(number of total entries to cut and paste is 80)
John Doe
1111 Doe Street
123-4567
Map
Sally Anne
1111 Anne Street
765-4321
Map
Becomes:
John Doe 1111 Doe Street 123-4567 Map
Sally Anne 1111 Anne Street 765-4321 Map
tell application "Microsoft Excel"
activate object worksheet "Sheet1"
(* Make sure your list is on sheet 1 and you have a blank sheet 2 created *)
(* default search word is Map and default number of entires is 80 - change below if you like *)
set mycol1 to 1
set myrow1 to 1
(* Change the word Map below if you want a different keyword to search for *)
set nextmap to (find (range "A:A" of worksheet "Sheet1") what "Map")
get address nextmap
set mycol2 to first column index of nextmap
set myrow2 to first row index of nextmap
set rownumx to 1
(* increase rownumx final value below if you have more or fewer entries *)
repeat with rownumx from 1 to 80
set firstcel to (get address of cell mycol1 of row myrow1 of active sheet)
set lastcel to (get address of cell mycol2 of row myrow2 of active sheet)
set myrange to range (firstcel & ":" & lastcel)
select myrange
copy range myrange
paste special cell 1 of row rownumx of sheet 2 with transpose
set rownumbx to rownumx + 1
set myrow1 to myrow2 + 1
set nextmap to (find next (range "A:A" of worksheet "Sheet1") after nextmap)
get address nextmap
set mycol2 to first column index of nextmap
set myrow2 to first row index of nextmap
tell application "System Events" to set the clipboard to ""
end repeat
end tell
(*
next version would include a dialog box at the beginning that asks the user for the keyword which deliniates vertical groupings
also nice if it just applied to selection and not necessary to set final rownumx value manually
*)
AppleScript: 2.1.1
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)