Delete characters up to ":"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a report page that copies comment.txt from the source page (thanks again for help Tom). I'm wondering if it's possible to delete all characters up to and including the ":" on the report page. (This will get rid of the username info)

Robby

(Make it stop raining please, ty)
 
You can use InStr() to search for the colon and Mid() to ignore the stuff before
it.

Option Explicit
Sub testme()

Dim myStr As String
Dim colonPos As Long

myStr = "this is a test: for removing colons"

colonPos = InStr(1, myStr, ":")
If colonPos > 0 Then
myStr = Mid(myStr, colonPos + 1) '+2 to get rid of the linefeed?
End If

MsgBox myStr

End Sub
 
Ok Dave, playing around with it to see what I get. Thanks for the help. :)

Robbyn
 
Okay Dave. Can't sleep so played around with your code, and it most definitely works when I use activeCell. But the following code doesn't

Sub textme(

Dim myStr As Strin
Dim colonPos As Lon
Dim cell As Rang

For Each cell In Range("a1:a15"
myStr = cell.Valu
colonPos = InStr(1, myStr, ":"
If colonPos > 0 The
myStr = Mid(myStr, colonPos + 1
End I
Next cel

End Su

Any idea why? (thanks again

Robbyn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top