View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
William Benson[_2_] William Benson[_2_] is offline
external usenet poster
 
Posts: 230
Default Insert 19 cells "Shift to the right" if cell contains "-"

Hi,

You can use this. Remember, the key here is that once the range is found,
Excel will not find the next range unless you swap the text in the first
range for something else. Then, at the end, I swap the text back.

....Bill

Sub hhh()
Dim LoopEnd As Boolean
Dim SomeRange As Range
Const Txt = "SomeUnlikelyText"
Do While Not LoopEnd
Set SomeRange = Cells.Find(What:="-")
If SomeRange Is Nothing Then
LoopEnd = True
Else
SomeRange.Value = Application.Substitute(SomeRange.Value, "-", Txt)
SomeRange.Cut SomeRange.Offset(0, 19)
End If
Loop

Cells.Replace What:=Txt, Replacement:="-", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub


"robertjtucker"
wrote in message
news:robertjtucker.1sko2p_1122037851.4973@excelfor um-nospam.com...

I have been looking for a sub that can find a cell in column A that has
a "-" in it the actuall cell will contain "P-9999999" the only thing
consistant is the "-". When it finds the cell I need it to shift 19
cells to the Right.
Thanks for the help or any ideas,
Bob


--
robertjtucker
------------------------------------------------------------------------
robertjtucker's Profile:
http://www.excelforum.com/member.php...o&userid=21805
View this thread: http://www.excelforum.com/showthread...hreadid=389337