Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is wrong with the loop condition in this code?
The purpose of the code is to remove all the spaces before the first character in a column of selected worksheet cells like this: F 1 R H T U N 25.05 8.80 35.38 27.50 24.25 26.00 27.50 22.88 where each row is a value in a cell of a column in the worksheet. When I run the code on these cell values, the test condition, testStr = Left(nxtChar, 1), is never satisified. Thank you. John Wirt Public Sub RemoveSpace() Dim nxtChar As String, testStr As String Dim rngTxt As Range Dim rw As Range testStr = Left(" ", 1) Set rngTxt = Selection For Each rw In rngTxt.Rows nxtChar = rw.Cells(1, 1).Value Do nxtChar = Mid(nxtChar, 2, Len(nxtChar) - 1) Loop While testStr = Left(nxtChar, 1) rw.Value = nxtChar Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
countif and sum if if two condition are satisfied | Excel Worksheet Functions | |||
Looping till condition is satisfied? | Excel Worksheet Functions | |||
Deleting columns if condition is satisfied | Excel Programming | |||
Copy sheets only if condition is satisfied (mat) | Excel Programming | |||
How to change the value of a cell when a condition is satisfied, but not otherwise? | Excel Discussion (Misc queries) |