Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use excel to correlate key credentials. My keys are in this format xxxx-xx, where 'x' can be a letter or number. Is there any way to format the cells so that I don't have to type the "-" every time? and it will sort properly?

share|improve this question

I don't think this is possible directly (see the documentation on formats in Excel).

However, you could use a formula like =CONCATENATE(LEFT(A1,4),"-",RIGHT(A1,2)) to create a formatted column.

share|improve this answer

Very similar to the above, but in some sense "easier" to change.

WARNING, untested code; it works in open LibreOffice though ;-).

Press ALT-F11

Insert a module, then type this into the editor window:

function alphaFmt(s as string) 

   if len(s)>2 then
   end if

end function

Then type:


in any cell, replace VALUE by either a literal string, cell reference or formula building a string.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .