Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
kdw
 
Posts: n/a
Default custom format & saving

Is there a way to save this format type so I can use it in another workbook?
The custom format only stays in the workbook it was created in.

Also, how do I create a format for something like 12-34-5F or 12-34-56?
00-00-00 works if all digits but won't work in the first example. @@-@@-@@
just repeats everything nor does @-@-@ work.

Thanks!
  #2   Report Post  
bj
 
Posts: n/a
Default

Unfortunately, I think the best way for you to do this is to enter it as
text. (put a hyphen before your entry)

"kdw" wrote:

Is there a way to save this format type so I can use it in another workbook?
The custom format only stays in the workbook it was created in.

Also, how do I create a format for something like 12-34-5F or 12-34-56?
00-00-00 works if all digits but won't work in the first example. @@-@@-@@
just repeats everything nor does @-@-@ work.

Thanks!

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

I bet bj meant the apostrophe ('), not the hyphen (-).



bj wrote:

Unfortunately, I think the best way for you to do this is to enter it as
text. (put a hyphen before your entry)

"kdw" wrote:

Is there a way to save this format type so I can use it in another workbook?
The custom format only stays in the workbook it was created in.

Also, how do I create a format for something like 12-34-5F or 12-34-56?
00-00-00 works if all digits but won't work in the first example. @@-@@-@@
just repeats everything nor does @-@-@ work.

Thanks!


--

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

senior moment

"Dave Peterson" wrote:

I bet bj meant the apostrophe ('), not the hyphen (-).



bj wrote:

Unfortunately, I think the best way for you to do this is to enter it as
text. (put a hyphen before your entry)

"kdw" wrote:

Is there a way to save this format type so I can use it in another workbook?
The custom format only stays in the workbook it was created in.

Also, how do I create a format for something like 12-34-5F or 12-34-56?
00-00-00 works if all digits but won't work in the first example. @@-@@-@@
just repeats everything nor does @-@-@ work.

Thanks!


--

Dave Peterson

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

You can create a workbook template and save it to your XLStart folder (save it
as book.xlt).

Then put everything you want new workbooks based on that template to
inherit--custom formats, page layouts, headers/footers, etc.

Then when you click on that New Icon, the new workbook will inherit all these
settings.

And numberformats work with numbers.

You could use a worksheet event that looks for changes and changes the values in
those cells to the nice format you like.

If you want to try this, rightclick on the worksheet tab that should have this
behavior. Select view code. Paste this into the code window.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myCell As Range
Dim myRng As Range
Dim myStr As String

Set myRng = Intersect(Target, Me.Range("a:a"))

If myRng Is Nothing Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
For Each myCell In myRng.Cells
With myCell
If IsNumeric(.Value) Then
.NumberFormat = "00-00-00"
ElseIf Len(.Value) = 6 Then
.Value = Left(.Value, 2) & "-" & _
Mid(.Value, 3, 2) & "-" & _
Right(.Value, 2)
End If
End With
Next myCell
Application.EnableEvents = True
On Error GoTo 0

End Sub

Change this line to just the range that you want "formatted":
Set myRng = Intersect(Target, Me.Range("a:a"))
(I used all of column A.)

And if you typed in a number, I changed the format. If you typed in text, I
changed the value.

kdw wrote:

Is there a way to save this format type so I can use it in another workbook?
The custom format only stays in the workbook it was created in.

Also, how do I create a format for something like 12-34-5F or 12-34-56?
00-00-00 works if all digits but won't work in the first example. @@-@@-@@
just repeats everything nor does @-@-@ work.

Thanks!


--

Dave Peterson


  #6   Report Post  
kdw
 
Posts: n/a
Default

Dave, I tried your approach of using the Change Event and it worked, although
it isn't quite what I was looking for originally. I'll have to keep this
piece of code in my 'folder' for future reference.

I gather that the short answer to my question is that we can't create Custom
Format for non-numbers ( at least not in the Format Cell menu). I wonder if
this has changed in the newer version of Excel?

"Dave Peterson" wrote:

You can create a workbook template and save it to your XLStart folder (save it
as book.xlt).

Then put everything you want new workbooks based on that template to
inherit--custom formats, page layouts, headers/footers, etc.

Then when you click on that New Icon, the new workbook will inherit all these
settings.

And numberformats work with numbers.

You could use a worksheet event that looks for changes and changes the values in
those cells to the nice format you like.

If you want to try this, rightclick on the worksheet tab that should have this
behavior. Select view code. Paste this into the code window.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myCell As Range
Dim myRng As Range
Dim myStr As String

Set myRng = Intersect(Target, Me.Range("a:a"))

If myRng Is Nothing Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
For Each myCell In myRng.Cells
With myCell
If IsNumeric(.Value) Then
.NumberFormat = "00-00-00"
ElseIf Len(.Value) = 6 Then
.Value = Left(.Value, 2) & "-" & _
Mid(.Value, 3, 2) & "-" & _
Right(.Value, 2)
End If
End With
Next myCell
Application.EnableEvents = True
On Error GoTo 0

End Sub

Change this line to just the range that you want "formatted":
Set myRng = Intersect(Target, Me.Range("a:a"))
(I used all of column A.)

And if you typed in a number, I changed the format. If you typed in text, I
changed the value.

kdw wrote:

Is there a way to save this format type so I can use it in another workbook?
The custom format only stays in the workbook it was created in.

Also, how do I create a format for something like 12-34-5F or 12-34-56?
00-00-00 works if all digits but won't work in the first example. @@-@@-@@
just repeats everything nor does @-@-@ work.

Thanks!


--

Dave Peterson

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

Yep. When excel says NumberFormat, it means number format <vbg.



kdw wrote:

Dave, I tried your approach of using the Change Event and it worked, although
it isn't quite what I was looking for originally. I'll have to keep this
piece of code in my 'folder' for future reference.

I gather that the short answer to my question is that we can't create Custom
Format for non-numbers ( at least not in the Format Cell menu). I wonder if
this has changed in the newer version of Excel?

"Dave Peterson" wrote:

You can create a workbook template and save it to your XLStart folder (save it
as book.xlt).

Then put everything you want new workbooks based on that template to
inherit--custom formats, page layouts, headers/footers, etc.

Then when you click on that New Icon, the new workbook will inherit all these
settings.

And numberformats work with numbers.

You could use a worksheet event that looks for changes and changes the values in
those cells to the nice format you like.

If you want to try this, rightclick on the worksheet tab that should have this
behavior. Select view code. Paste this into the code window.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myCell As Range
Dim myRng As Range
Dim myStr As String

Set myRng = Intersect(Target, Me.Range("a:a"))

If myRng Is Nothing Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
For Each myCell In myRng.Cells
With myCell
If IsNumeric(.Value) Then
.NumberFormat = "00-00-00"
ElseIf Len(.Value) = 6 Then
.Value = Left(.Value, 2) & "-" & _
Mid(.Value, 3, 2) & "-" & _
Right(.Value, 2)
End If
End With
Next myCell
Application.EnableEvents = True
On Error GoTo 0

End Sub

Change this line to just the range that you want "formatted":
Set myRng = Intersect(Target, Me.Range("a:a"))
(I used all of column A.)

And if you typed in a number, I changed the format. If you typed in text, I
changed the value.

kdw wrote:

Is there a way to save this format type so I can use it in another workbook?
The custom format only stays in the workbook it was created in.

Also, how do I create a format for something like 12-34-5F or 12-34-56?
00-00-00 works if all digits but won't work in the first example. @@-@@-@@
just repeats everything nor does @-@-@ work.

Thanks!


--

Dave Peterson


--

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 06:51 PM.

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

About Us

"It's about Microsoft Excel"