ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing semicolons (https://www.excelbanter.com/excel-programming/324013-removing-semicolons.html)

JA[_3_]

Removing semicolons
 
This macros just received works but does not seem to stop
the looping until it returs the error "MS Visual Basic
400".
I would appreciate a bit of tweaking.

i = 1
Do
Target = Range("D" & i)
TargetLength = Len(Target)
CharLeft = Left(Target, 1)
CharRight = Right(Target, 1)

If CharLeft = ";" Then Target = Right(Target, Len
(Target) - 1)
If CharRight = ";" Then Target = Left(Target, Len
(Target) - 1)

Range("D" & i) = Target
i = i + 1
Loop


[email protected]

Removing semicolons
 
JA,

Add
If IsEmpty(Range("D" & i)) = True Then Exit Do
after the
i=i+1
This checks for empty cells. There are quite a few of different
Is.....functions that may suit you better
depending upon your cell contents.
Do you need to check across your columns and change the D to an E
etc....

Donna



All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com