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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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,215,636
Messages
6,125,959
Members
449,276
Latest member
surendra75

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