Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
In my excel sheet I have data such as : MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 I need to delete all the "-" and leave: MAC103234234 MAC103234234 MAC103234234 MAC103234234 Any suggestions?? Cheers Manny |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
select the column and do
Edit=Replace What - With leave blank -- Regards, Tom Ogilvy "Mannyluk" wrote in message ... Hi, In my excel sheet I have data such as : MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 I need to delete all the "-" and leave: MAC103234234 MAC103234234 MAC103234234 MAC103234234 Any suggestions?? Cheers Manny |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Needs to be done in a macro.
But thanks anyway "Tom Ogilvy" wrote: select the column and do Edit=Replace What - With leave blank -- Regards, Tom Ogilvy "Mannyluk" wrote in message ... Hi, In my excel sheet I have data such as : MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 I need to delete all the "-" and leave: MAC103234234 MAC103234234 MAC103234234 MAC103234234 Any suggestions?? Cheers Manny |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() The code would be: Sub Test() For Each r In Range("A1:A4") r.Value = Replace(r.Value, "-", "") Next End Sub Substitute your a range for A1:A4. -- kkkni ----------------------------------------------------------------------- kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754 View this thread: http://www.excelforum.com/showthread.php?threadid=27081 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just turn on the macro recorder while you do it manually.
It is a single command. What could be simpler. Here, I will do it for you: Sub ReplaceHyphen() Columns(1).Replace What:="-", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False End Sub -- Regards, Tom Ogilvy "Mannyluk" wrote in message ... Needs to be done in a macro. But thanks anyway "Tom Ogilvy" wrote: select the column and do Edit=Replace What - With leave blank -- Regards, Tom Ogilvy "Mannyluk" wrote in message ... Hi, In my excel sheet I have data such as : MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 I need to delete all the "-" and leave: MAC103234234 MAC103234234 MAC103234234 MAC103234234 Any suggestions?? Cheers Manny |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just a thought since you said nothing but "the code would be", then
presented a different approach than what was suggest by me. Using the Replace Method without looping would be much faster than using the replace function in a loop. For 4 cells, it wouldn't be noticeable, but for 1000 (for example) it would. -- Regards, Tom Ogilvy "kkknie" wrote in message ... The code would be: Sub Test() For Each r In Range("A1:A4") r.Value = Replace(r.Value, "-", "") Next End Sub Substitute your a range for A1:A4. K -- kkknie ------------------------------------------------------------------------ kkknie's Profile: http://www.excelforum.com/member.php...fo&userid=7543 View this thread: http://www.excelforum.com/showthread...hreadid=270816 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Mannyluk" wrote in message ...
Hi, In my excel sheet I have data such as : MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 I need to delete all the "-" and leave: MAC103234234 MAC103234234 MAC103234234 MAC103234234 Any suggestions?? Cheers Manny This will select the entire current region and remove all -. If you want to do it by a column use Columns("A:A").Select instead of Selection.CurrentRegion.Select. Fred ------ Sub remove_hyphen() Selection.CurrentRegion.Select Selection.Replace What:="-", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False End Sub ------- |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Mannyluk" wrote in message ...
Hi, In my excel sheet I have data such as : MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 MAC-103-234-234 I need to delete all the "-" and leave: MAC103234234 MAC103234234 MAC103234234 MAC103234234 Any suggestions?? Cheers Manny Actually all you need is this: ----- Sub remove_hyphen() Selection.CurrentRegion.Select Selection.Replace What:="-", Replacement:="" End Sub ------ TIP: What I did was record a Macro doing it manually like Tom reccomended. Then just cleaned up the code. Fred |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Tom, You are 100% correct. When I wrote "The code would be", I should hav said "a code that will work but may not be the best possible would be" Much appologies. K P.S. Thank you for the denigration -- kkkni ----------------------------------------------------------------------- kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754 View this thread: http://www.excelforum.com/showthread.php?threadid=27081 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
One Last Thing | Excel Discussion (Misc queries) | |||
one more thing | Excel Worksheet Functions | |||
Doing it's own thing | Excel Programming | |||
Another thing | Excel Programming | |||
oh, and another thing | Excel Programming |