#1   Report Post  
maryj
 
Posts: n/a
Default custom format

What would the custom format be for something like this:
CL-123-4567

--
maryj
  #2   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

That is not a number, it is text, AFAIK you can customize text format,
however if
it always starts with CL and then you want 3 numbers dash and 4 numbers you
can use

"CL-"000-0000

and type in 1234567

and it will come out that way


Regards,

Peo Sjoblom

"maryj" wrote:

What would the custom format be for something like this:
CL-123-4567

--
maryj

  #3   Report Post  
maryj
 
Posts: n/a
Default

The letters at the beginning may not always be the same. Also, did you mean
to say that this can or can not be done with text?
--
maryj


"Peo Sjoblom" wrote:

That is not a number, it is text, AFAIK you can customize text format,
however if
it always starts with CL and then you want 3 numbers dash and 4 numbers you
can use

"CL-"000-0000

and type in 1234567

and it will come out that way


Regards,

Peo Sjoblom

"maryj" wrote:

What would the custom format be for something like this:
CL-123-4567

--
maryj

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Number formatting means numbers.

But you could use another cell (column of cells) that does your formatting.

If you type this in A1:
cl1234567
you could use a formula like:
=upper(left(a1,2))&"-"&mid(a1,3,3)&"-"&mid(a1,6,4)
(and copy down)

In fact, you could set up a few rows:
=if(a1="","",upper(left(a1,2))&"-"&mid(a1,3,3)&"-"&mid(a1,6,4))

Another option would be to use an event macro that looks for data in your range
and fixes it the way you specify.

If you want to try that, this assumes that the strings are always 9 characters
and you're typing them anywhere in column A:

Just rightclick on the worksheet tab that should have this behavior. Select
View code and paste this in the code window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo errHandler:
With Target
If .Cells.Count 1 Then Exit Sub
If Intersect(.Cells, Me.Range("a:a")) Is Nothing Then Exit Sub
If .HasFormula Then Exit Sub
If Len(.Value) < 9 Then Exit Sub

Application.EnableEvents = False
.Value = UCase(Left(.Value, 2)) & "-" & Mid(.Value, 3, 3) _
& "-" & Mid(.Value, 6, 4)
End With

errHandler:
Application.EnableEvents = True
End Sub

maryj wrote:

The letters at the beginning may not always be the same. Also, did you mean
to say that this can or can not be done with text?
--
maryj

"Peo Sjoblom" wrote:

That is not a number, it is text, AFAIK you can customize text format,
however if
it always starts with CL and then you want 3 numbers dash and 4 numbers you
can use

"CL-"000-0000

and type in 1234567

and it will come out that way


Regards,

Peo Sjoblom

"maryj" wrote:

What would the custom format be for something like this:
CL-123-4567

--
maryj


--

Dave Peterson
  #5   Report Post  
maryj
 
Posts: n/a
Default

Thanks Dave. I was hoping we could do this with just formatting, but I
figured it would involve this type of formula.
--
maryj


"Dave Peterson" wrote:

Number formatting means numbers.

But you could use another cell (column of cells) that does your formatting.

If you type this in A1:
cl1234567
you could use a formula like:
=upper(left(a1,2))&"-"&mid(a1,3,3)&"-"&mid(a1,6,4)
(and copy down)

In fact, you could set up a few rows:
=if(a1="","",upper(left(a1,2))&"-"&mid(a1,3,3)&"-"&mid(a1,6,4))

Another option would be to use an event macro that looks for data in your range
and fixes it the way you specify.

If you want to try that, this assumes that the strings are always 9 characters
and you're typing them anywhere in column A:

Just rightclick on the worksheet tab that should have this behavior. Select
View code and paste this in the code window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo errHandler:
With Target
If .Cells.Count 1 Then Exit Sub
If Intersect(.Cells, Me.Range("a:a")) Is Nothing Then Exit Sub
If .HasFormula Then Exit Sub
If Len(.Value) < 9 Then Exit Sub

Application.EnableEvents = False
.Value = UCase(Left(.Value, 2)) & "-" & Mid(.Value, 3, 3) _
& "-" & Mid(.Value, 6, 4)
End With

errHandler:
Application.EnableEvents = True
End Sub

maryj wrote:

The letters at the beginning may not always be the same. Also, did you mean
to say that this can or can not be done with text?
--
maryj

"Peo Sjoblom" wrote:

That is not a number, it is text, AFAIK you can customize text format,
however if
it always starts with CL and then you want 3 numbers dash and 4 numbers you
can use

"CL-"000-0000

and type in 1234567

and it will come out that way


Regards,

Peo Sjoblom

"maryj" wrote:

What would the custom format be for something like this:
CL-123-4567

--
maryj


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell will not format numbers correctly for a 13 digit custom barc. Laudan Excel Worksheet Functions 4 April 11th 05 08:13 PM
Keep custom format in new worksheet Buddy Excel Discussion (Misc queries) 2 March 14th 05 10:03 AM
How do I format a cell for a custom part number? PJ Excel Discussion (Misc queries) 4 March 3rd 05 03:57 AM
Custom Format for ¢ Stephen POWELL Excel Discussion (Misc queries) 0 February 25th 05 07:11 PM
Custom Time Format doesn't work for me chuck Excel Discussion (Misc queries) 1 February 13th 05 04:12 AM


All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"