View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Search and replace blanks

Hi Samantha,

Try:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set WB = Workbooks("YourBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet1") '<<===== CHANGE
Set rng = SH.Range("A1:D30") '<<===== CHANGE

For Each rCell In rng.Cells
With rCell
If Not IsEmpty(.Value) Then
If Not .Value Like "*[A-Z]*" Then
.Replace What:=" ", Replacement:=""
End If
End If
End With
Next rCell

End Sub
'<<=============

--
---
Regards,
Norman



"SamanthaK" wrote in message
...
How do you search an entier spreadsheet and do the following:

1) Check if the contents of a cell is numeric?
2) If content is numeric then search for blanks (" ") and replace them
with
nothing (""). E.g. I hace a number in a cell written like: 1000 22 458 but
want to convert it to 100022458. I do not want text like: 'Market value'
to
be replaced by 'Marketvalue'.

Please help me on this one!!!
--
I am very thankful for any fast assistance!