VBA Replace "-"

JMC57

Board Regular
Joined
Apr 24, 2012
Messages
118
I need to find a way to find and repalce using VBA so that 00904-0201-61 converts to 904020161 or 12345-6789-11 converts to to 12345678911 by removing the - between then numbers.


ActiveSheet.Columns("C").NumberFormat = "@" or ActiveSheet.Columns("C").NumberFormat = "00000-0000-00"</SPAN> do not allow ther esult to be viewed as a number when doing VLOOKUP. When I use find and replace teh VLOOKUP works.

Having VBA do the find and erpalce will help expedite the formating.

Thanks
</SPAN>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try code below
Code:
Sub Test()
With Columns("C:C")
    .Cells.Replace What:="-", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    .EntireColumn.AutoFit
End With
End Sub
 
Upvote 0
No problems m8.
I know becuz I have hard time sleeping with tough vba and SQL questions too.

Biz
 
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,995
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top