LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default character.delete doesn't work

Hi!

I have created a loop in vb which deletes unnecessary spaces like this:

For i = 1 To langd - 1

If c.Characters(i, 1).Text = " " Then
While c.Characters(i + 1, 1).Text = " "
c.Characters(i + 1, 1).Delete
Wend
End If

Next

This is nested inside a "For each c in range..." and has never failed until
applied on on a cell containing this text:

Trädgårdsg 31, Trädgårdsg 26, Trädgårdsg 23, Trädgårdsg 21, Trådgårdsg 30,
Tingstug 16, Sörgärdsg 22, Sörgärdsg 20, Rådmansg 1, Nyg 23, Nikanderg 9,
Nikanderg 6, Nikanderg 11, Järnvägsg 4, Hospitalsg 15, Gyllenhjelmsg Fh 18,
Brinkska V 2 FH, Brinkska V 2 A

c.characters.count returns 257 and the loop gets stuck on character 218, the
space after Gyllenhjelmsg where there are two spaces. The line
"c.Characters(i + 1, 1).Delete" is then excecuted, but it seems like it
doesn't work since the while-statement is then evaluated as true, resulting
in an eternal loop. What is the problem? And does anyone have a nice solution?

Thanks
Stefan
 
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
Delete everything after a certain character [email protected] Excel Programming 4 November 21st 06 09:04 PM
IF statements with * character doesn't work [email protected] Excel Worksheet Functions 5 November 8th 06 03:47 PM
Delete all occurrences of a character Harleygrrl814 New Users to Excel 8 May 11th 05 05:15 PM
Delete ascii character 127 CyndyG Excel Programming 2 May 4th 05 10:38 PM
Delete everything after a certain character? Chris Excel Programming 2 June 18th 04 09:59 PM


All times are GMT +1. The time now is 10:35 AM.

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"