Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding and moving hypens from end to beginning of cell

Hi,

I want to be able to find and change all ###- entries
into -### in a worksheet (or a selected range). i.e. Move
the hyphen from the end of the cell to the beginning
(negative number) and remove any spaces that may be at the
beginning or end of the cell.

Thanks for any help.

Example
123-(space) change to -123
(space)234- -234
12-%(space) -12%
(space)-(space) leave as is or remove spaces
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding and moving hypens from end to beginning of cell


Amy,

A find & replace operation on the affected cells needs to be done to
find all spaces and replace them with nothing. (that means do not type
anything in the replace with box).

Most of the cells should now be numeric and excell will recognise them
as such.

If any cells are still being treated as text, then in an empty part of
your worksheet enter a 1 ( the number that is).
Copy that cell. (with the 1 in it)
Highlight all of your data cells and use paste special multiply .
This will cause excel to treat all of the cells as numbers.

Fianlly to move the minus sign.
That is dealt with in online help concerning number formats, of you
could use the pre-worked formats supplied with excel.
Either way, the area you need to work with is in the cellsformat
menu.

Hope it helps


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Finding and moving hypens from end to beginning of cell

Sub ConvertMinus()
Dim sStr As String
For Each cell In Selection.SpecialCells(xlConstants, xlTextValues)
sStr = Application.Substitute(Trim(cell), " ", "")
If InStr(sStr, "-") Then
sStr = Application.Substitute(sStr, "-", "")
If Len(sStr) < 0 Then
If InStr(sStr, "%") Then
sStr = Application.Substitute(sStr, "%", "")
If IsNumeric(Left(sStr, Len(sStr) - 1)) Then
cell.Value = CDbl(sStr) / 100
cell.NumberFormat = "#%"
End If
Else
If IsNumeric(Left(sStr, Len(sStr) - 1)) Then
cell.Value = CDbl(sStr)
End If
End If
End If
End If
Next

End Sub


Worked with your examples.

--
Regards,
Tom Ogilvy



--
Regards,
Tom Ogilvy


"Amy" wrote in message
...
Hi,

I want to be able to find and change all ###- entries
into -### in a worksheet (or a selected range). i.e. Move
the hyphen from the end of the cell to the beginning
(negative number) and remove any spaces that may be at the
beginning or end of the cell.

Thanks for any help.

Example
123-(space) change to -123
(space)234- -234
12-%(space) -12%
(space)-(space) leave as is or remove spaces



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
finding and then moving entire row to new sheet based on cell value dave chamberlan Excel Discussion (Misc queries) 2 November 17th 09 01:27 AM
Finding average beginning at first cell in row 0? MJW[_2_] Excel Discussion (Misc queries) 4 November 28th 07 09:25 PM
how can I remove hypens from a field ty Excel Discussion (Misc queries) 2 January 8th 07 07:51 PM
finding blank cell and moving specific data into it BeJay Excel Worksheet Functions 1 May 30th 06 07:06 PM
Automatically moving a chart range at the beginning of the next month altoonaPillarRock Excel Programming 0 November 14th 03 06:21 AM


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