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

Range("A1").Select
Cells.REPLACE What:="1-", Replacement:="-1", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True

I want to use this formula to replace ALL cells where the "-" symbol is on
the right by moving it to the left in front of the number.

This formula works great, but only for cells with "1-"...if the number is
any different I'd have to set it up for every possible number which would be
a rediculously long macro. Any ideas on how I can modify this? THANKS!!!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default REPLACE

Check out this link...

http://www.mcgimpsey.com/excel/postfixnegatives.html
--
HTH...

Jim Thomlinson


"bodhisatvaofboogie" wrote:

Range("A1").Select
Cells.REPLACE What:="1-", Replacement:="-1", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True

I want to use this formula to replace ALL cells where the "-" symbol is on
the right by moving it to the left in front of the number.

This formula works great, but only for cells with "1-"...if the number is
any different I'd have to set it up for every possible number which would be
a rediculously long macro. Any ideas on how I can modify this? THANKS!!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default REPLACE

This is only for cells containing data, not formulae:

Sub negatory()
For Each r In Selection
With r
If Right(.Value, 1) = "-" Then
.Value = "-" & Left(.Value, Len(.Value) - 1)
End If
End With
Next
End Sub

--
Gary''s Student - gsnu2007


"bodhisatvaofboogie" wrote:

Range("A1").Select
Cells.REPLACE What:="1-", Replacement:="-1", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True

I want to use this formula to replace ALL cells where the "-" symbol is on
the right by moving it to the left in front of the number.

This formula works great, but only for cells with "1-"...if the number is
any different I'd have to set it up for every possible number which would be
a rediculously long macro. Any ideas on how I can modify this? THANKS!!!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default REPLACE



"Gary''s Student" wrote:

This is only for cells containing data, not formulae:

Sub negatory()
For Each r In Selection
With r
If Right(.Value, 1) = "-" Then
.Value = "-" & Left(.Value, Len(.Value) - 1)
End If
End With
Next
End Sub

--
Gary''s Student - gsnu2007


"bodhisatvaofboogie" wrote:

Range("A1").Select
Cells.REPLACE What:="1-", Replacement:="-1", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True

I want to use this formula to replace ALL cells where the "-" symbol is on
the right by moving it to the left in front of the number.

This formula works great, but only for cells with "1-"...if the number is
any different I'd have to set it up for every possible number which would be
a rediculously long macro. Any ideas on how I can modify this? THANKS!!!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default REPLACE

That worked great, Thanks!!!

"Gary''s Student" wrote:

This is only for cells containing data, not formulae:

Sub negatory()
For Each r In Selection
With r
If Right(.Value, 1) = "-" Then
.Value = "-" & Left(.Value, Len(.Value) - 1)
End If
End With
Next
End Sub

--
Gary''s Student - gsnu2007


"bodhisatvaofboogie" wrote:

Range("A1").Select
Cells.REPLACE What:="1-", Replacement:="-1", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True

I want to use this formula to replace ALL cells where the "-" symbol is on
the right by moving it to the left in front of the number.

This formula works great, but only for cells with "1-"...if the number is
any different I'd have to set it up for every possible number which would be
a rediculously long macro. Any ideas on how I can modify this? THANKS!!!


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
Can I replace a ' at the beginning of a text cell using Replace Hilde Excel Discussion (Misc queries) 4 September 10th 07 06:22 PM
Replace text with variable using VBA replace code? Mike[_112_] Excel Programming 2 November 9th 06 06:06 PM
How to Replace multiple words to replace using excell ramsun Excel Programming 1 August 10th 06 01:52 PM
find and replace - replace data in rows to separated by commas msdker Excel Worksheet Functions 1 April 15th 06 01:00 AM
Replace method - cannot find any data to replace Mike Excel Programming 5 April 6th 06 08:56 PM


All times are GMT +1. The time now is 02:29 AM.

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"