parsing script

  • Thread starter Thread starter Mary Beth
  • Start date Start date
M

Mary Beth

I think I'm not using quite the right term here.

Sub Tester()

s = ActiveCell.Value
sParseTerm = Selection.Offset(0,
1).Range(ActiveCell.Address).Value
TermPos = InStr(1, s, sParseTerm, vbTextCompare)
If TermPos > 0 Then
s = Left(s, TermPos - 2) & Mid(s, TermPos + Len(sParseTerm))
ActiveCell.Value = s
End If

sParseTerm = Selection.Offset(0,
2).Range(ActiveCell.Address).Value
TermPos = InStr(1, s, sParseTerm, vbTextCompare)
If TermPos > 0 Then
s = Left(s, TermPos - 2) & Mid(s, TermPos + Len(sParseTerm))
ActiveCell.Value = s
End If

End Sub

This line doesn't seem to do quite what I'm thinking it does.
sParseTerm = Selection.Offset(0, 1).Range(ActiveCell.Address).Value

I think it should be taking the address of the active cell, and getting
the value of the cell next to it. Unfortunately, I think it's actually
taking a value from the 1rst row, 2nd column or something.

Is there a different term I should be using?
 
Mary Beth,

If you want the value of the cell next to the active cell the statement
should be

sParseTerm = Selection.Offset(0, 1)

Regards,
Shockley
 

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