Hello,
After much deliberation, I was able to write a routine that determined the length of characters(including " ") in a cell, then using mid statement replaced until there were no more " "
Dim j As Long, varVal As Variant, lVal As Variant
For j = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
varVal = Cells(j, 1).Value
lVal = Len(varVal)
Do Until Mid(varVal, lVal, 1) <> " "
If Mid(varVal, lVal, 1) = " " Then
Cells(j, 1).Value = Mid(varVal, 1, lVal - 1)
lVal = lVal - 1 'This line
End If
Loop
Next j
The problem I was having was resetting the Len(varVal). I kept trying to write:
Len(varVal)=Len(varVal)-1
but was not resetting the Length. Then I dimmed variant lVal and set it to equal variant varVal and this worked. Conceptually, this is new ground for me. By defining a variant from an existing variant, am I foraging into ReDim territory?
Thanks............Mickey
After much deliberation, I was able to write a routine that determined the length of characters(including " ") in a cell, then using mid statement replaced until there were no more " "
Dim j As Long, varVal As Variant, lVal As Variant
For j = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
varVal = Cells(j, 1).Value
lVal = Len(varVal)
Do Until Mid(varVal, lVal, 1) <> " "
If Mid(varVal, lVal, 1) = " " Then
Cells(j, 1).Value = Mid(varVal, 1, lVal - 1)
lVal = lVal - 1 'This line
End If
Loop
Next j
The problem I was having was resetting the Len(varVal). I kept trying to write:
Len(varVal)=Len(varVal)-1
but was not resetting the Length. Then I dimmed variant lVal and set it to equal variant varVal and this worked. Conceptually, this is new ground for me. By defining a variant from an existing variant, am I foraging into ReDim territory?
Thanks............Mickey