Editing text in cell

D

donwb

Win XP, Excel 2003
Is it possible to Tab the insertion point for text in a cell.
Say I want to type "Someword" then a Tab space then "Anotherword."
Using the Tab key alone or with combinations of Shift, Ctrl and Alt doesn't
do it.
Strangely though, Alt + RETURN will move the insertion point to the next
line.
If it is not possible with keyboard strokes, can it be done
programmatically?
I have got as far as:-
ActiveSheet.Range("A1").Select
SendKeys "{F2}", True
DoEvents
(to put the cell into the Edit mode, which it does, then)
SendKeys "{Tab}", True
DoEvents
(to tab the insertion point, but it doesn't)
Help please
 
G

Gary''s Student

The following sub:

Sub dural()
Set r = ActiveCell
r.Value = "Someword" & Chr(9) & "Anotherword"
End Sub

will get you the desired result of inserting a tab inside text. You don't
need SendKeys to do this.
 
D

donwb

Hi
The code you suggest puts the following text:-
"SomewordAnotherword" (with no tab) into the cell,
-which is what I would expect, but with a tab.

What I want to know is how I insert a Tab into the existing text.
at an insertion point of my choosing.

I would still like to know if this can be done using the keyboard.
Don
 
G

Gary''s Student

I see what you mean. The code I posted does insert a TAB character between
the two words. See:

http://www.techonthenet.com/ascii/chart.php

In Word, the TAB character is used to display text aligned to fixed columns.
The same is true for most word processors. In Excel, however, the TAB
character does not have that effect. It is just another character in the
string. It is usually displayed as a small square.

I don't know how to get the "TAB" effect in Excel that is the same as Word.
 

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