Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am looking for a piece of VBA that will remove all characters/spaces to the left of the minus sign. All values are in Column D. I could have data in any Row between 2 & 500, of any value
Example is " EURO -491.15 So I just want it to appear in cells as -491.15 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Am Fri, 24 Jul 2015 22:37:54 -0700 (PDT) schrieb : Example is " EURO -491.15 So I just want it to appear in cells as -491.15 try: Sub Replace() Dim LRow As Long Dim rngC As Range LRow = Cells(Rows.Count, 4).End(xlUp).Row For Each rngC In Range("D2:D" & LRow) rngC = Mid(rngC, InStr(rngC, "-")) Next End Sub Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Getting a debug on this line
rngC = Mid(rngC, InStr(rngC, "-")) "invalid procedure or call arguement" Note that I have removed all " -EURO values already, if thats the issue, so would would to trap that error so it doesnt happen if format is OK |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Am Sat, 25 Jul 2015 02:12:29 -0700 (PDT) schrieb : Note that I have removed all " -EURO values already, if thats the issue, so would would to trap that error so it doesnt happen if format is OK please post some of your strings. Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Saturday, July 25, 2015 at 10:28:03 AM UTC+1, Claus Busch wrote:
Hi, Am Sat, 25 Jul 2015 02:12:29 -0700 (PDT) schrieb : Note that I have removed all " -EURO values already, if thats the issue, so would would to trap that error so it doesnt happen if format is OK please post some of your strings. Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional -491.15 -742.00 Details above, not row 2 is blank |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Am Sat, 25 Jul 2015 02:57:12 -0700 (PDT) schrieb : -491.15 -742.00 but that is your expected output. You don't need a macro. Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Saturday, July 25, 2015 at 11:10:41 AM UTC+1, Claus Busch wrote:
Hi, Am Sat, 25 Jul 2015 02:57:12 -0700 (PDT) schrieb : -491.15 -742.00 but that is your expected output. You don't need a macro. Correct, but that was after 'manual' adjustment, I'll be adding again to the column next week. i.e. I copy/paste from a flat file, hence the " EURO etc etc |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Am Sat, 25 Jul 2015 03:18:59 -0700 (PDT) schrieb : Correct, but that was after 'manual' adjustment, I'll be adding again to the column next week. i.e. I copy/paste from a flat file, hence the " EURO etc etc then try: Sub Replace() Dim LRow As Long Dim rngC As Range LRow = Cells(Rows.Count, 4).End(xlUp).Row For Each rngC In Range("D2:D" & LRow) If InStr(rngC, "-") Then rngC = Mid(rngC, InStr(rngC, "-")) End If Next End Sub Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Great, that seems to work perfect
One other twist, in Column E, I have similar format, except it doesn't have the - (minus sign) e.g " EURO 659.00 How could I also run the code over this column? |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much, will save me a lot of manual adjustment going forward
|
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Am Sat, 25 Jul 2015 05:11:39 -0700 (PDT) schrieb : Thank you very much, will save me a lot of manual adjustment going forward you are welcome. Always glad to help. Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
View code for removal of unwanted text in cells | Excel Discussion (Misc queries) | |||
Linking cells/duplicate removal | Excel Discussion (Misc queries) | |||
Removal of empty cells in an Excel table | Excel Programming | |||
req :Mackro for removal for emplyspaces in cells ? | Excel Programming | |||
Removal of characters from a range of cells | Excel Worksheet Functions |