Thread: Edit a Cell
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Edit a Cell

Try it this way

Sub inserttext()
tti = InputBox("Text to insert")
at = "Now is the time"
With ActiveCell ' or range("b2")
x = InStr(.Value, at)
tr = Right(.Value, Len(.Value) - Len(at) - x + 1)
'MsgBox Left(.Value, x + Len(at)) & "" & tti & tr
..Value = Left(.Value, x + Len(at)) & "" & tti & tr
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Gary''s Student" wrote in message
...
I have a cell that already contains some text. I need a macro that:

1. selects the cells
2. opens it for editting (like touching F2)
3. positions the editting cursor just after the third character in the
cell

So, for example, if the cell contains:

Now is the time

and the user runs the macro, any text the user types next would be entered
just after the Now

My first attempt was:

Sub editt()
Range("B2").Select
Application.SendKeys ("{F2}")
For i = 1 To 100
Application.SendKeys ("{LEFT}")
Next
For i = 1 To 3
Application.SendKeys ("{RIGHT}")
Next
End Sub

This works, but only for machines that accept SendKeys.

I can't figure out how to enter edit mode without SendKeys ??
--
Gary''s Student - gsnu200827