#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Format Text

How can i format text by macro for K1234567 to K-123-45-67


Thanks,
Kevin
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Format Text

Why a macro...Here is a formula to do it...

=LEFT(A1, 1) &"-" & MID(A1, 2, 3) &"-" & MID(A1, 5, 2) &"-" & MID(A1, 7, 2)

With your text in cell A1
--
HTH...

Jim Thomlinson


"Tazflerts" wrote:

How can i format text by macro for K1234567 to K-123-45-67


Thanks,
Kevin

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Format Text

Hey Gents,

Thanks for the response.

To answer the question: The data returned is from a msquery from other
tables in the workbook. This occupies from Column A to U. To use the
formula would mean inserting or using a column for the formula but when the
data is refreshed it would mean recalibrating the formulas again.

Instead i have implemented the formula provided in a macro and then create a
button with the macro assigned to it. This way the maro runs on the specific
column and return the changes to the same column.

This is the macro::::::

Public Sub NISFormat()

Dim rCell As Range

For Each rCell In Selection.Cells



With rCell



.Value = Left(rCell.Value, 1) & "-" & Mid(rCell.Value, 2, 2)
& "-" & Right(rCell.Value, 4)



End With



Next rCell

End Sub

:::::::::::::::::::::::::::::::::

Thanks again.

"Jim Thomlinson" wrote:

Why a macro...Here is a formula to do it...

=LEFT(A1, 1) &"-" & MID(A1, 2, 3) &"-" & MID(A1, 5, 2) &"-" & MID(A1, 7, 2)

With your text in cell A1
--
HTH...

Jim Thomlinson


"Tazflerts" wrote:

How can i format text by macro for K1234567 to K-123-45-67


Thanks,
Kevin

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,276
Default Format Text

Hi,
you can use

=LEFT(B12,1)&"-"&MID(B12,2,3)&"-"&MID(B12,5,2)&"-"&MID(B12,7,2)

"Tazflerts" wrote:

How can i format text by macro for K1234567 to K-123-45-67


Thanks,
Kevin

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
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Excel Worksheet Functions 6 June 2nd 09 08:14 PM
Change Date Format to Specific Text Format When Copying [email protected] Excel Discussion (Misc queries) 4 December 23rd 08 03:43 PM
Convert numbers from text format to number format merlin68 Excel Discussion (Misc queries) 7 June 20th 07 07:03 PM
how to format excel format to text format with separator "|" in s. azlan New Users to Excel 1 January 31st 05 12:57 PM
How do i change numbers in text format to number format? Greg New Users to Excel 1 December 14th 04 05:22 PM


All times are GMT +1. The time now is 03:21 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"