This Excel-free test version of the script works perfectly for me, both when creating the person in the group and when adding it after creation. (Contacts 12.0, macOS 10.14.6 (supplementary update), Script Editor and Script Debugger.) If it works for Mick536 too, it would suggest something wrong with the values coming out of Excel. What does TEMP look like after its values are set?
If this script doesn’t work for Mick536, it would suggest some problem with Contacts.
But first try quitting Contacts to clear any unsaved work from previous script runs.
set Cohort to "Cohort Test" -- Group name. Change if required.
tell application "Contacts"
activate
if not (group Cohort exists) then
make new group with properties {name:Cohort}
save
end if
end tell
set j to 10
repeat with i from 2 to j
set TEMP to {key:i - 1, LastName:"Bloggs", FirstName:"Bill", MI:"Bertie", Rank:"", |Hash|:"Huh?", |Nickname|:"Fishface", Srvc:"BSA & handlebar", Corps:"Sergeant", Addressline1:"3 Railway Cuttings", |City|:"Coventry", |State|:"", |Zip|:"CV1 1AB", HomePhone:"01234 70526", |Email|:"", ParentMilitaryCommand:"Royal Arquebusiers", MobilePhone:"07569 406789", WorkPhone:"", EmailDomain:""}
set |Email| of TEMP to some item of {"fface@gmail.mil", "bbbloggs@gmail.gov", "billb99@gmail.com"}
set EmailDomain of TEMP to my rightstr(|Email| of TEMP, 4)
tell application "Contacts"
-- Create the person in the group.
set theStudent to make new person at group Cohort with properties ¬
{last name:(LastName of TEMP), first name:(FirstName of TEMP), middle name:(MI of TEMP), title:(Rank of TEMP), note:("Cohort: " & Cohort & linefeed & "Hash: " & |Hash| of TEMP), nickname:(|Nickname| of TEMP), suffix:(Srvc of TEMP), job title:(Corps of TEMP), organization:(ParentMilitaryCommand of TEMP)}
(* -- Or create the person to add to the group later.
set theStudent to make new person with properties ¬
{last name:(LastName of TEMP), first name:(FirstName of TEMP), middle name:(MI of TEMP), title:(Rank of TEMP), note:("Cohort: " & Cohort & linefeed & "Hash: " & |Hash| of TEMP), nickname:(|Nickname| of TEMP), suffix:(Srvc of TEMP), job title:(Corps of TEMP), organization:(ParentMilitaryCommand of TEMP)} *)
if EmailDomain of TEMP is ".mil" then
make new email at end of every email of theStudent with properties ¬
{label:"Work", value:(|Email| of TEMP)}
else if EmailDomain of TEMP is ".gov" then
make new email at end of every email of theStudent with properties ¬
{label:"Work", value:(|Email| of TEMP)}
else
make new email at end of every email of theStudent with properties ¬
{label:"Home", value:(|Email| of TEMP)}
end if
make new phone at end of every phone of theStudent with properties ¬
{label:"Work", value:(WorkPhone of TEMP)}
make new phone at end of every phone of theStudent with properties ¬
{label:"Home", value:(HomePhone of TEMP)}
make new phone at end of every phone of theStudent with properties ¬
{label:"Mobile", value:(MobilePhone of TEMP)}
make new address at end of every address of theStudent with properties ¬
{label:"Home", street:(Addressline1 of TEMP), city:(|City| of TEMP), state:(|State| of TEMP), zip:(|Zip| of TEMP)}
set cls to class of theStudent
-- add theStudent to group Cohort
end tell
end repeat
tell application "Contacts" to save
on rightstr(txt, N)
set C to length of txt
if N > C then set N to C
return text -N thru C of txt
end rightstr