Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete everything after a certain character | Excel Programming | |||
IF statements with * character doesn't work | Excel Worksheet Functions | |||
Delete all occurrences of a character | New Users to Excel | |||
Delete ascii character 127 | Excel Programming | |||
Delete everything after a certain character? | Excel Programming |