ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding & Deleting Spaces from Cells (https://www.excelbanter.com/excel-programming/289324-finding-deleting-spaces-cells.html)

SUDHENDRA

Finding & Deleting Spaces from Cells
 
Hi

I have a text file from main frame which i am importing
into excel.

The problem i have is, some of the cells have 256 spaces
in them,i want to delete them by code.. I need to find
these cells which are having 256 spaces in 31 columns
and 'n' number of rows.

Can any one suggest some idea/code please

Thanks inadvance


mudraker[_126_]

Finding & Deleting Spaces from Cells
 
This code replaces 256 spaces with nothing


Need to do this in 2 steps as trying to replace 256 spaces in one ste
gives an error message... 255 seems to be the maximum



Sub Macro1()
Sheets("SHEET1").Cells.Replace What:=Space(156), Replacement:=""
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Sheets("SHEET1").Cells.Replace What:=Space(100), Replacement:=""
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Su

--
Message posted from http://www.ExcelForum.com


SUDHENDRA

Finding & Deleting Spaces from Cells
 
Thanks very much...

But I want i dont want to replace 256 space but i want to
clear those cells...

how to do if i do not know how many blank spaces are
there

any more ideas please
-----Original Message-----
This code replaces 256 spaces with nothing


Need to do this in 2 steps as trying to replace 256

spaces in one step
gives an error message... 255 seems to be the maximum



Sub Macro1()
Sheets("SHEET1").Cells.Replace What:=Space(156),

Replacement:="",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Sheets("SHEET1").Cells.Replace What:=Space(100),

Replacement:="",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub


---
Message posted from http://www.ExcelForum.com/

.



All times are GMT +1. The time now is 06:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com