Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Getting rid of char(160)

Hi Folks!

I recorded a macro to clean the range selected of char(160)'s and attached
it to a button on one of my toolbars.

It's not working. Here's the code from the macro recorder:

Sub Clean160()

Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub

The actual recorded code included as the first line:

Range("A1:A10").Select

I figured since that referenced a specific range I could just remove that
line and since the next line starts with Selection, that referred to any
range selected. Is that the problem?

Also, how does the code:

Selection.Replace What:=" ",

know that " " is char(160) and not char(32)?

I tried replacing =" " with =char(160) but that errored.

Thanks!

Biff



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Getting rid of char(160)

Biff,

Try
Selection.Replace what:=Chr(160), replacement:=" "

or in the Replace dialog box, hold down the ALT key and type 0160
on the numeric keypad (not the number keys above the letters).



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Biff" wrote in message
...
Hi Folks!

I recorded a macro to clean the range selected of char(160)'s
and attached it to a button on one of my toolbars.

It's not working. Here's the code from the macro recorder:

Sub Clean160()

Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False

End Sub

The actual recorded code included as the first line:

Range("A1:A10").Select

I figured since that referenced a specific range I could just
remove that line and since the next line starts with Selection,
that referred to any range selected. Is that the problem?

Also, how does the code:

Selection.Replace What:=" ",

know that " " is char(160) and not char(32)?

I tried replacing =" " with =char(160) but that errored.

Thanks!

Biff





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,688
Default Getting rid of char(160)

Thanks, Chip!

Selection.Replace what:=Chr(160)

Worked!

Biff

"Chip Pearson" wrote in message
...
Biff,

Try
Selection.Replace what:=Chr(160), replacement:=" "

or in the Replace dialog box, hold down the ALT key and type 0160 on the
numeric keypad (not the number keys above the letters).



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Biff" wrote in message
...
Hi Folks!

I recorded a macro to clean the range selected of char(160)'s and
attached it to a button on one of my toolbars.

It's not working. Here's the code from the macro recorder:

Sub Clean160()

Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub

The actual recorded code included as the first line:

Range("A1:A10").Select

I figured since that referenced a specific range I could just remove that
line and since the next line starts with Selection, that referred to any
range selected. Is that the problem?

Also, how does the code:

Selection.Replace What:=" ",

know that " " is char(160) and not char(32)?

I tried replacing =" " with =char(160) but that errored.

Thanks!

Biff







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FIND 1 char in cell of any 3 char =True Nastech Excel Discussion (Misc queries) 5 April 26th 08 02:17 PM
8500 cells with phone number(7 char.), wishing to add area code (10 char.) [email protected] Excel Discussion (Misc queries) 6 March 10th 06 05:13 PM
About NUM to CHAR balaneeds Excel Programming 3 June 27th 05 03:26 PM
Get rid of CHAR(12) CLR Excel Programming 8 January 15th 05 03:32 AM
How to removed the first three char and last char in XLS Lillian Excel Programming 1 December 21st 04 12:34 AM


All times are GMT +1. The time now is 09:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"