View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Removing section of a string in VBA

One way:

Dim sTemp As String
Dim nPos As Long
sTemp = Sheets("Sheet1").Range("A1").Text
nPos = InStr(sTemp, ")")
If nPos 0 Then sTemp = LTrim(Mid(sTemp, nPos + 1))
nPos = InStr(sTemp, "-")
If nPos 0 Then sTemp = RTrim(Left(sTemp, nPos - 1))
Sheets("Sheet2").Range("A1").Value = sTemp

or, equivalently:

With Sheets("Sheet1").Range("A1")
Sheets("Sheet2").Range("A1").Value = _
Trim(Mid(Left(.Text, InStr(.Text, "-") - 1), _
InStr(.Text, ")") + 1))
End With



In article . com,
"Jake Wiley" wrote:

Hi I have a worksheet with a column of goals (for teachers) and some
directions. For example:
1) Student work samples - A sample of student work needs to be
presented and dated.
This is all in one cell
2) Parent Involvement Folder - Proof of parent consent must be
presented
and so on and so on
I just need:
Student work samples
Parent Involvement Folder

I need to carry over the goal to another sheet which I already did
based on some info but I don't need the number preceeding the goal AND
the instructions following the -
There is no set number of characters because each goal is different.

Please if anybody could point me in the right direction