View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Macro to insert a cell after the selected cell

Sorry...inserted at the wrong place:

Sub pointr()
inpt = Application.InputBox(Prompt:="enter input", Type:=2)
outp = Application.InputBox(Prompt:="enter output", Type:=2)
Set rPush = Nothing
For Each r In ActiveSheet.UsedRange
If r.Value = inpt Then
If rPush Is Nothing Then
Set rPush = r
Else
Set rPush = Union(rPush, r)
End If
End If
Next
rPush.Offset(0, 1).Insert Shift:=xlToRight
rPush.Offset(0, 1).Value = outp
End Sub

--
Gary''s Student - gsnu200836


"PointerMan" wrote:

This macro inserted a blank cell before the input cell. It didn't enter my
output information into the output cell, either.

"Gary''s Student" wrote:

Sub pointr()
inpt = Application.InputBox(Prompt:="enter input", Type:=2)
outp = Application.InputBox(Prompt:="enter output", Type:=2)
Set rPush = Nothing
For Each r In ActiveSheet.UsedRange
If r.Value = inpt Then
If rPush Is Nothing Then
Set rPush = r
Else
Set rPush = Union(rPush, r)
End If
End If
Next

rPush.Insert Shift:=xlToRight
rPush.Offset(0, 1).Value = outp
End Sub

--
Gary''s Student - gsnu200836