![]() |
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!!! |
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!!! |
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!!! |
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!!! |
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!!! |
All times are GMT +1. The time now is 03:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com