ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to remove ";" (https://www.excelbanter.com/excel-programming/323955-macro-remove-%3B.html)

JA[_3_]

Macro to remove ";"
 
This macro suggested for my previous question is
returning the error sub or function not defined.
Can some tweak it for me.

Sub Test()

Dim NewStr As String

NewStr = Replace(MyStr, ";;", ";")
If Mid(NewStr, 1, 1) = ";" Then NewStr = Right
(NewStr, Len(NewStr) - 1)
If Right(NewStr, 1) = ";" Then NewStr = Left(NewStr,
Len(NewStr) - 1)
If InStr(NewStr, ";;") Then NewStr = Clean(NewStr)
SemiClean = NewStr


End Sub



K Dales[_2_]

Macro to remove ";"
 
Because it is a recursive function (it calls itself) it needs to be a
function, needs the string to be converted passed to it, and needs to be
named "SemiClean"

"JA" wrote:

This macro suggested for my previous question is
returning the error sub or function not defined.
Can some tweak it for me.

Sub Test()

Dim NewStr As String

NewStr = Replace(MyStr, ";;", ";")
If Mid(NewStr, 1, 1) = ";" Then NewStr = Right
(NewStr, Len(NewStr) - 1)
If Right(NewStr, 1) = ";" Then NewStr = Left(NewStr,
Len(NewStr) - 1)
If InStr(NewStr, ";;") Then NewStr = Clean(NewStr)
SemiClean = NewStr


End Sub




Dave D-C[_3_]

Macro to remove ";"
 
maybe you want
Sub zReplace()
On Error Resume Next
Do While Not ActiveSheet.UsedRange.Find(";;") Is Nothing
' *.Replace() should return False, but it doesn't on my xl97
Call ActiveSheet.UsedRange.Replace( _
";;", ";", xlPart, xlByRows, False)
Loop
On Error Goto 0
End Sub

"JA" wrote:

This macro suggested for my previous question is
returning the error sub or function not defined.
Can some tweak it for me.

Sub Test()

Dim NewStr As String

NewStr = Replace(MyStr, ";;", ";")
If Mid(NewStr, 1, 1) = ";" Then NewStr = Right
(NewStr, Len(NewStr) - 1)
If Right(NewStr, 1) = ";" Then NewStr = Left(NewStr,
Len(NewStr) - 1)
If InStr(NewStr, ";;") Then NewStr = Clean(NewStr)
SemiClean = NewStr


End Sub



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


All times are GMT +1. The time now is 09:13 PM.

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