View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Coderre Ron Coderre is offline
external usenet poster
 
Posts: 698
Default sorting excel data

Well!....I sure munged up that code!
I started out intending to use Find/Replace....then changed my mind and with
with iterative code. (sorry)

This is what I SHOULD have posted:

'--------Start of Code-------
Option Explicit

Sub FixDashNums()
Dim rngSelection As Range
Dim cCell As Range

Set rngSelection = Selection

With rngSelection
For Each cCell In .Cells
If cCell.Value Like "*-?" Then
cCell.Replace What:="-", Replacement:="-0"
End If
Next cCell
End With

End Sub
'--------End of Code-------

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Ron Coderre" wrote:

Don't look for Excel to record *that* macro properly <g

Try this:

'--------Start of Code-------
Option Explicit

Sub FixDashNums()
Dim rngSelection As Range
Dim cCell As Range

Set rngSelection = Selection

With rngSelection
If .Cells.Count = 1 Then
If MsgBox( _
Title:="Please Confirm", _
Prompt:="Only 1 cell selected...." _
& "OK to fix ALL cells in the worksheet?", _
Buttons:=vbQuestion + vbYesNo) _
= vbNo Then
Exit Sub
End If
Else
For Each cCell In .Cells
If cCell.Value Like "*-?" Then
cCell.Replace What:="-", Replacement:="-0"
End If
Next cCell
End If
End With

End Sub
'--------End of Code-------

To run it....Select the range to be impacted...
Then.....[Alt]+[F8]....Select "FixDashNums"....Click [Run]

Does that help?
***********
Regards,
Ron

XL2002, WinXP


" wrote:

Thanks Ron!

this seems to work nicely. Only problem I have now, is that if i try
to record this method into a macro, that _all_ my data receive their
extra '0' after the dash, so in some way the selection method for
numbers with only 1 digit behind the dash is not recorded into the
macro (ie: 60000-12 becomes 60000-012, which is not supposed to
happen). Can anybody help me out with that?

thanks in advance,
Leon

On 11 jul, 15:04, Ron Coderre
wrote:
You might be interested in resolving the basic issue....

[snip]

Is that something you can work with?
***********
Regards,
Ron