Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Replacing spaces with zeros

I have the following

Sub FillZeros()

Sheets("Records").Select
Range("N2:N500").Select
Application.CutCopyMode = False
Cells.Replace What:="", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False

End Sub

When I run it I get 5 additional cols of zeros

Oldjay
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Replacing spaces with zeros

Try: Selection.Replace instead of Cells.Replace

HTH
--
AP

"Oldjay" a écrit dans le message de news:
...
I have the following

Sub FillZeros()

Sheets("Records").Select
Range("N2:N500").Select
Application.CutCopyMode = False
Cells.Replace What:="", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False

End Sub

When I run it I get 5 additional cols of zeros

Oldjay



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Replacing spaces with zeros

Thanks everybody

"Ardus Petus" wrote:

Try: Selection.Replace instead of Cells.Replace

HTH
--
AP

"Oldjay" a Ʃcrit dans le message de news:
...
I have the following

Sub FillZeros()

Sheets("Records").Select
Range("N2:N500").Select
Application.CutCopyMode = False
Cells.Replace What:="", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False

End Sub

When I run it I get 5 additional cols of zeros

Oldjay




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Replacing spaces with zeros

Cells.Replace What:="", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False


This statement replaces empty strings "".

Try

Cells.Replace What:=" ", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False


but first check that you want to replace all spaces in all cells
(LookAt:=xlPart) or only those standing alone in a cell (LookAt:=xlWhole)

Regards,
Stefi

€˛Oldjay€¯ ezt Ć*rta:

I have the following

Sub FillZeros()

Sheets("Records").Select
Range("N2:N500").Select
Application.CutCopyMode = False
Cells.Replace What:="", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False

End Sub

When I run it I get 5 additional cols of zeros

Oldjay

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Replacing spaces with zeros


Sub FillZeros()

Sheets("Records").Select
Range("N2:N500").Select
Application.CutCopyMode = False
Selection.Replace What:="", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False

End Sub
--
Regards,
Tom Ogilvy


"Oldjay" wrote:

I have the following

Sub FillZeros()

Sheets("Records").Select
Range("N2:N500").Select
Application.CutCopyMode = False
Cells.Replace What:="", Replacement:=0, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False

End Sub

When I run it I get 5 additional cols of zeros

Oldjay



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
Replacing spaces with data from another cell Michael Excel Discussion (Misc queries) 2 December 16th 09 01:18 AM
Replacing spaces with a line end Fat Doris Excel Discussion (Misc queries) 5 February 19th 09 09:51 AM
Replacing spaces in text, with another character PCLIVE Excel Worksheet Functions 2 October 14th 05 06:43 PM
Replacing specific characters with spaces Night Owl Excel Worksheet Functions 3 May 13th 05 05:52 PM
replacing spaces? No Name Excel Programming 5 May 25th 04 04:04 AM


All times are GMT +1. The time now is 07:28 PM.

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

About Us

"It's about Microsoft Excel"