adding to a VBA COde

D

diacci1st

Hi
The below code I am running works ok but I need to add an other part to it
as this one:
If Left(s, 1) = "1" Then
i = 183
iloc = InStr(i, s, " ", vbTextCompare)
t = 202
tloc = InStr(t, s, " ", vbTextCompare)

s1 = Left(s, i - 1)
s3 = Right(s, Len(s) - iloc)
s2 = "*************** "
Cell.Value = s1 & s2 & s3
But I am not too sure how to do it....
could you please help?
Sub AABB()

For Each Cell In Range("A1:A65000")
s = Cell.Value
If Left(s, 1) = "1" Then
i = 208
iloc = InStr(i, s, " ", vbTextCompare)
t = 223
tloc = InStr(t, s, " ", vbTextCompare)

s1 = Left(s, i - 1)
s3 = Right(s, Len(s) - iloc)
s2 = "*************** "
Cell.Value = s1 & s2 & s3


ElseIf Left(s, 1) = "2" Then
i = 61
iloc = InStr(i, s, " ", vbTextCompare)
t = 76
tloc = InStr(t, s, " ", vbTextCompare)


s1 = Left(s, i - 1)
s3 = Right(s, Len(s) - tloc)
s2 = "*************** "
Cell.Value = s1 & s2 & s3

Else

End If
Next
Cells.Select
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
 

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

Top