change content in a cell

Schnet

New Member
Joined
Nov 30, 2005
Messages
8
I have a column with numbers in that format:
289-231-5274
but I need them without the "-"
How can I change that with the help of a macro?
Thanks
Schnet
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> DashZapper()
Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
<SPAN style="color:#00007F">With</SPAN> Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row).SpecialCells(xlCellTypeConstants) <SPAN style="color:#007F00">'</SPAN>
    .Replace What:="-", Replacement:="", LookAt:=xlPart
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
 
Upvote 0
Thank you very much!
Would you mind to explain me how that exactly works?
I worked with macros before but I'm still a beginner.
Schnet
 
Upvote 0
Schnet said:
Thank you very much!
Would you mind to explain me how that exactly works?
I worked with macros before but I'm still a beginner.
Schnet

The code simply calls Excel's native Replace function; the only thing "special" about it might be the designation of the range to search - it is limited to

a] column A only, and

b] only those cells having constant values - no formulas and ignore blanks, too.

Screen updating is turned off then back on because

a] you don't really need to see the screen flicker when it runs, but more importantly

b] it should run faster not having to update the screen but 1 time, when finished.
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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