#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell format

I have an issue I think can be solved with a Custom Cell Format. The problem
is I'm not sure how to write the format. I have a Name column formated as
General. The data looks like this in each cell: Smith1234, John
How do I reformat the cell to knock out the numbers and leave me with Smith,
John. Manually doing this would be consuming as I am trying to change about
4000 entries. Thanks in advance for any help!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Cell format

You can use a macro.
But in your case, you don't need to scan through all 4000 entries which could be time consuming. You can use another approach, which is to find and replace all numeric value in the cells. ie. from 0 to 9.

So, select the range of cells to clean up, and run the following macro.

Sub Macro1()
Dim tmp As Integer
With Selection
For tmp = 0 To 9
.Replace What:=tmp, Replacement:=""
Next
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Cell format


Sub RemoveNums()
'' Remove numeric characters from a string.
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Not (Mid(rngR.Value, intI, 1)) Like "[0-9]" Then
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub

Gord Dibben Excel MVP

On Tue, 13 Jan 2004 19:38:43 -0700, "N Sabo" wrote:

I have an issue I think can be solved with a Custom Cell Format. The problem
is I'm not sure how to write the format. I have a Name column formated as
General. The data looks like this in each cell: Smith1234, John
How do I reformat the cell to knock out the numbers and leave me with Smith,
John. Manually doing this would be consuming as I am trying to change about
4000 entries. Thanks in advance for any help!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Cell format

Just My 2 cents:

Sub FixName()
Dim Comma1 As String, StrChk As Variant, Cnt
Dim LR As Long
Application.ScreenUpdating = False
LR = ActiveCell.SpecialCells(xlLastCell).Row
Cnt = 1
Range("A1").Activate
Comma1 = InStr(1, ActiveCell.Value, ",")
Do
Do
StrChk = Mid(ActiveCell.Value, Comma1 - Cnt, 1)
If IsNumeric(StrChk) = True Then
Cnt = Cnt + 1
Else
ActiveCell.Value = Left(ActiveCell.Value, Comma1 -
Cnt) _
& " " & Mid(ActiveCell.Value, Comma1 + 2, Len
(ActiveCell.Value))
End If
Loop Until IsNumeric(StrChk) = False
ActiveCell.Offset(1).Activate
Cnt = 1
Comma1 = InStr(1, ActiveCell.Value, ",")
Loop Until ActiveCell.Row LR

End Sub

HTH


-----Original Message-----
I have an issue I think can be solved with a Custom Cell

Format. The problem
is I'm not sure how to write the format. I have a Name

column formated as
General. The data looks like this in each cell:

Smith1234, John
How do I reformat the cell to knock out the numbers and

leave me with Smith,
John. Manually doing this would be consuming as I am

trying to change about
4000 entries. Thanks in advance for any help!


.

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
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
cell format - remove cell format pattern without effecting colors Bas Excel Discussion (Misc queries) 1 March 23rd 09 02:54 PM
Can cell format come from and change with reference cell format jclouse Excel Discussion (Misc queries) 1 November 29th 06 03:20 AM
How do I copy data in single cell format to a merged cell format Paul Excel Discussion (Misc queries) 1 June 27th 05 11:00 AM


All times are GMT +1. The time now is 05:45 AM.

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"