close

question: i recorded a macro that involves replacing the character quot;pquot;
in the part numbers after I run the macro with a nuLL string quot;quot;....but
i want the macro to replace the p only in the first index not anywhere
else in the part number: Here is part of my code.

Columns(quot;A:Aquot;).Select
Selection.Find(What:=quot;pquot;, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Selection.Replace What:=quot;pquot;, Replacement:=quot;quot;, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Hope this helps.You could do this with a cell formula. Put the following in the first row of
another column and copy down.

=IF(LEFT(A1,1)=quot;pquot;,RIGHT(A1,LEN(A1)-1),A1)

If you'd rather use a macro, you could loop through each cell and use a
similar formula in vba, but it's not quite as simple. Let us know if you
need the code.

quot;dexquot; wrote:

gt; question: i recorded a macro that involves replacing the character quot;pquot;
gt; in the part numbers after I run the macro with a nuLL string quot;quot;....but
gt; i want the macro to replace the p only in the first index not anywhere
gt; else in the part number: Here is part of my code.
gt;
gt; Columns(quot;A:Aquot;).Select
gt; Selection.Find(What:=quot;pquot;, After:=ActiveCell, LookIn:=xlFormulas,
gt; LookAt _
gt; :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
gt; MatchCase:= _
gt; False, SearchFormat:=False).Activate
gt; Selection.Replace What:=quot;pquot;, Replacement:=quot;quot;, LookAt:=xlPart, _
gt; SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
gt; ReplaceFormat:=False
gt;
gt; Hope this helps.
gt;
gt;

Yes i would rather use it in the macro. What is the syntax?See if this does what you want.

Sub Fordex()
For Each c In Range(quot;A:Aquot;)
If StrConv(Left(c.Value, 1), vbUpperCase) = quot;Pquot; Then
c.Value = Right(c.Value, Len(c.Value) - 1)
End If
Next
End Subquot;dexquot; wrote:

gt; Yes i would rather use it in the macro. What is the syntax?
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()