Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Removing Everything behing 3 Spaces

Hello,

I hope somebody can help me with this.
I have a colum and in that colum are differect cells with text. Example

OPTERON 250 2.4GHZ FSB1000 CHIP

Like you see there are a fex spaces and the nthe word CHIP.
I'm looking for a code finding that is scanning the row (In this case Row.C)
Finding the cells containing the three spaces and removing everything
followed after the spaces.

The final result will be

OPTERON 250 2.4GHZ FSB1000

Is there anyway to fix this?

Thanks already for all your help!
Rony

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Removing Everything behing 3 Spaces

I hope somebody can help me with this.
I have a colum and in that colum are differect cells with text. Example

OPTERON 250 2.4GHZ FSB1000 CHIP

Like you see there are a fex spaces and the nthe word CHIP.
I'm looking for a code finding that is scanning the row (In this case
Row.C)
Finding the cells containing the three spaces and removing everything
followed after the spaces.

The final result will be

OPTERON 250 2.4GHZ FSB1000

Is there anyway to fix this?


Either test for the 3 spaces first, like this...

If InStr(YourString, " ") Then
<TheCell'sValue = Left$(<TheCell'sValue, InStr(YourString, " ") - 1)
End If

or, if there aren't thousands of cell's involved, just run each cell through
this...

<TheCell'sValue = Left$(YourString, InStr(<TheCell'sValue & " ", "
") - 1)

where you would, of course, put the actual reference to the cell from your
loop in place of my place-holder (<TheCellValue).

Rick

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Removing Everything behing 3 Spaces

One way -

Sub test()

Rem3space ActiveSheet.Columns(3)

End Sub

Sub Rem3space(rng As Range)
Dim pos As Long
Dim s As String
Dim cel As Range, rngTextCells As Range

On Error Resume Next
Set rngTextCells = rng.SpecialCells(xlCellTypeConstants, 2)
On Error GoTo 0
If rngTextCells Is Nothing Then Exit Sub

For Each cel In rngTextCells
s = cel.Value
pos = InStr(1, s, " ")
If pos Then
cel = Left(s, pos - 1)
End If
Next

End Sub

I assume when you say "Row C" you mean Column-C !

Regards,
Peter T

"Rony" wrote in message
...
Hello,

I hope somebody can help me with this.
I have a colum and in that colum are differect cells with text. Example

OPTERON 250 2.4GHZ FSB1000 CHIP

Like you see there are a fex spaces and the nthe word CHIP.
I'm looking for a code finding that is scanning the row (In this case

Row.C)
Finding the cells containing the three spaces and removing everything
followed after the spaces.

The final result will be

OPTERON 250 2.4GHZ FSB1000

Is there anyway to fix this?

Thanks already for all your help!
Rony



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
removing extra spaces BVZ Excel Discussion (Misc queries) 2 October 29th 08 07:21 PM
Removing Spaces Gary Excel Discussion (Misc queries) 15 January 9th 08 01:14 PM
removing all spaces jamesea Excel Discussion (Misc queries) 4 May 27th 07 02:18 PM
Removing spaces from value using VBA Barb Reinhardt Excel Programming 9 August 3rd 06 08:51 PM
removing spaces Claus Massmann Excel Discussion (Misc queries) 12 March 30th 06 02:23 AM


All times are GMT +1. The time now is 02:19 AM.

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"