Democrat (later Republican) Strom Thurmond was elected in 1954 to the United States Senate in South Carolina as a write-in candidate.
House of Representatives
Democrat Dale Alford was elected as a write-in candidate to the United States House of Representatives in Arkansas in 1958. As member of the Little Rock school board, Alford launched his write-in campaign a week before the election because the incumbent, Brooks Hays, was involved in the incident in which president Eisenhower sent federal troops to enforce racial integration at Little Rock Central High School. Racial integration was unpopular at the time, and Alford won by approximately 1,200 votes, a 2% margin.
Ron Packard of California finished in second place in the 18 candidate Republican primary to replace the retiring Clair Burgener. Packard lost the primary by 92 votes in 1982, and then mounted a write-in campaign as an independent. He won the election with a 37% plurality against both a Republican and a Democratic candidate. Following the elections, he re-aligned himself as a Republican.
Democrat Charlie Wilson was the endorsed candidate by the Democratic Party for the 6th congressional district in Ohio to replace Ted Strickland in 2006. Strickland was running for Governor and had to give up his congressional seat. Wilson, though, did not qualify for the ballot because only 46 of the 96 signatures on his candidacy petition were deemed valid, while 50 valid signatures were required for ballot placement. The Democratic Party continued to support Wilson, and an expensive primary campaign ensued - over $1 million was spent by both parties. Wilson overwhelmingly won the Democratic primary as a write-in candidate on May 2, 2006 against two Democratic candidates whose names were on the ballot, with Wilson collecting 44,367 votes, 67% of the Democratic votes cast. Wilson faced Republican Chuck Blasdel in the general election on November 7, 2006, and won, receiving 61% of the votes.
Charlotte Burks won as a Democratic write-in candidate for the Tennessee State Senate seat left vacant when the incumbent, her husband Tommy, was assassinated by his opponent, Byron Looper, two weeks before the elections of November 2, 1998. Because the assassination occurred only two weeks prior to the elections, the names of the dead incumbent and his assassin remained on the ballot, and Charlotte ran as a write in candidate.
Carl Hawkinson of Galesburg, Illinois won the Republican primary for State Senator from Illinois' 47th District in 1986 as a write-in candidate. He went on to be elected in the general election and served until 2003. Hawkinson defeated another write-in, David Leitch, in the primary. Incumbent State Senator Prescott Bloom died in a home fire after the filing date for the primary had passed.
There have been more than 23,000 Congressional elections in the United States during the 20th and 21st centuries, and a little less than 1,500 U.S. Senate elections in U.S. history. Just There have been roughly 125,000 state legislative elections in the 20th and 21st centuries. Each of those elections could have had two major party primary elections. So, about 73,500 potential federal elections and 375,000 state legislative elections produced just six write in winners.
Four federal elections have been won by write in candidates facing opponents on the ballot. Two were segregationists running on a segregationist platform. One used the process to circumvent the fact that he was defeated in the Republican party platform (Joe Lieberman later did the same thing as a third party candidate). Charlie Wilson of Ohio (not to be confused with Charlie Wilson of Texas who was the patron of U.S. involvement in the Afghan civil war as a proxy against the Soviets) would have been able to get on the ballot in Colorado, as parties can place candidates on the ballot without a petition through the caucus process.
In each of the two state legislative cases, there were dead men on the ballot, and situation could have been resolved by having voters vote for the dead man (not unprecedented in U.S. history) creating a vacancy.
Are there any cases in history where a write-in candidates opposed by a candidate on a ballot has been elected to a state or county elected office in Colorado? It has never happened in a federal election in Colorado.