Excel - Insert a Tab character inside cell

Asked By ryanmhu on 01-Mar-08 04:17 PM
I'm using Excel 2003 and would like to insert a tab character inside a
cell. I have tried CTRL + ALT + TAB to insert a tab chacater inside a
cell but nothing happens.

Does anyone know how to enter a tab character? Thanks




Gord Dibben replied on 01-Mar-08 12:44 PM
You cannot insert a Tab character in a cell.

You can insert a linefeed using Alt + Enter


Gord Dibben  MS Excel MVP
Rick Rothstein \(MVP - VB\) replied on 01-Mar-08 02:26 PM
Strange, it looks like you can concatenate a Tab character into a string,
but Excel won't show it to you. Enter this into A1...

="A"&CHAR(9)&"B"

(the ASCII value for the <horizontal> Tab character is 9) and put this in
B1...

=LEN(A1)

A length of 3 characters will be shown for A1, but there will appear to be
only 2 characters in it.

Rick
Gord Dibben replied on 01-Mar-08 02:41 PM
Rick

Using your formula I get A and the little hollow square Tab character and the B

But this does not constitute an in-cell Tab.

On the other hand  CHAR(10) will give you an in-cell line feed which responds to
Wrap Text formatting.


Gord

On Sat, 1 Mar 2008 14:26:55 -0500, "Rick Rothstein \(MVP - VB\)"
Rick Rothstein \(MVP - VB\) replied on 01-Mar-08 02:58 PM
Hmm! I wonder why I don't get the "hollow square". I'm using XL2003 on
Vista... I wonder if that matters? Or is there a "don't show unprintable
characters" option somewhere that I missed?

Still, it is a Tab character, it just seems like Excel doesn't do anything
display-wise with it. The character (invisible on my system, a hollow box on
yours) does retain its ASCII code value of 9 (which is the ASCII code value
of a Tab character); we can see this via this formula...

=CODE(MID(A1,2,1))

Rick
Pete_UK replied on 01-Mar-08 04:17 PM
Rick,

I get AB displayed (no hollow box), even with several CHAR(9)
characters in the formula. This is XL2k on Windows XP, fwiw.

Pete


on
e
d
,
n
be

t -
Gord Dibben replied on 01-Mar-08 04:28 PM
Excel 2003 SP3 and WindowsXP SP2 on my machine.

Don't know what determines whether or not the hollow box is visible or not.

Do you get the linefeed box when you Alt + Enter and disable wrap text?


Gord

On Sat, 1 Mar 2008 14:58:59 -0500, "Rick Rothstein \(MVP - VB\)"
Gord Dibben replied on 01-Mar-08 04:30 PM
In A1 enter  =CHAR(ROW())

Copy down.

Do you see hollow boxes down to A31?


Gord
Rick Rothstein \(MVP - VB\) replied on 01-Mar-08 04:55 PM
I don't... I see various symbols or empty squares. For example, at Row 14, I
see a music note symbol, at Row 17 I see a filled-in left-pointing triangle,
at Row 26 a right-pointing arrow, at Row 27 a left-pointing arrow, scattered
around in other positions are what looks like the old line drawing
characters from DOS days, and so on.

Rick
RagDyeR replied on 01-Mar-08 04:54 PM
What is your reason for inserting that tab?

What action exactly do you expect it to perform?
--

Regards,

RD
-----------------------------------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
-----------------------------------------------------------------------------------------------

I'm using Excel 2003 and would like to insert a tab character inside a
cell. I have tried CTRL + ALT + TAB to insert a tab chacater inside a
cell but nothing happens.

Does anyone know how to enter a tab character? Thanks
Rick Rothstein \(MVP - VB\) replied on 01-Mar-08 04:57 PM
No, I do not... the text is joined with nothing between them.

Rick
RagDyeR replied on 01-Mar-08 05:18 PM
Are you, by chance, using a custom font?
--

Regards,

RD
-----------------------------------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
-----------------------------------------------------------------------------------------------

I don't... I see various symbols or empty squares. For example, at Row 14, I
see a music note symbol, at Row 17 I see a filled-in left-pointing triangle,
at Row 26 a right-pointing arrow, at Row 27 a left-pointing arrow, scattered
around in other positions are what looks like the old line drawing
characters from DOS days, and so on.

Rick
Rick Rothstein \(MVP - VB\) replied on 01-Mar-08 05:21 PM
I am using Arial

Rick
Gord Dibben replied on 01-Mar-08 06:05 PM
That is the strangest darn thing.

Sounds like you have some kinda Dingbats font enabled for that column.

But you did answer Arial to RD's query so I have no ideas.


Gord
Roger Govier replied on 02-Mar-08 02:49 AM
Hi Rick

I see exactly the same as you in XL2003 on Vista SP1.
I just went to my wife's machine running XP professional and get the same
result.
XL2007 gives same result also on both operating systems

--
Regards
Roger Govier
Rick Rothstein \(MVP - VB\) replied on 02-Mar-08 03:39 AM
Thanks for the confirmation. I just fired up my copy of XL2007 and it too
displays the same symbols as my copy of XL2003 did. I'm not sure if I am at
Vista SP1 or not (how would I check that?). Interestingly enough, if you
highlight the column of symbols and change the font name, the symbols remain
(they change size, but I don't think their shapes are any different). If you
type text into one of those cells, the text is definitely in the newly
assigned font. So... anybody... what's going on here?

Rick
ryanmhu replied on 02-Mar-08 10:53 PM
I also get the block/square in excel 2003 on XP

I want to insert a tab character to indent the text but i don't want
to use the alignmen indent. This is because there is a program which
will read in the excel file and based on how many tabs precede the
text in the cell a specific action will be performed (The alignment
indent will not be counted as a tab so that will not work). I also
need the visual indentation as without you will not be able to see
what you are creating.

Perhaps there is not way to do this in excel.

On Mar 2, 3:39=A0am, "Rick Rothstein \(MVP - VB\)"
t
in
ou
e
in
g
on
w
e
h
ar
ed
BillyLidde replied on 02-Mar-08 04:29 PM
Hi

The OP said that he wanted to paste the stuff into another package.
Copying ="A"&CHAR(9)&"B" into Notepad returned "A (tab) B"
Trying the same in Word gave A B
Copying the formula into Word as Paste Special, RTF gave the correct
results. Maybe this will be sufficient for the OP.

Regards
Peter
Brendon Thiede replied on 02-Sep-08 11:30 AM
This post is a bit old, but if anyone stumbles across it (as I did) you can try this solution.  I created a "User Defined" function that just displays a series of spaces.  I also created a sub that when run will swap between the the "virtual tab" and an ASCII tab.  In general though, if you have an app that reads the file and treats tabs specially, I would think the best solution would be to use different columns (rather than tabs) and then save a copy as tab-delimited text.  Anyway, here's the code:



Option Explicit



Const TAB_INDENT_STRING As String = "      "



Public Function VirtualTab() As String

VirtualTab = TAB_INDENT_STRING

End Function





Public Sub ToggleVirtualTabs()

Dim rng As Range

Set rng = Cells.Find(What:="CHAR(9)", LookIn:=xlFormulas, LookAt:=xlPart, MatchCase:=False)



If rng Is Nothing Then

Set rng = Cells.Find(What:="VirtualTab()", LookIn:=xlFormulas, LookAt:=xlPart)

If Not rng Is Nothing Then

Cells.Replace What:="VirtualTab()", Replacement:="CHAR(9)", LookAt:=xlPart, MatchCase:=False

End If

Else

Cells.Replace What:="CHAR(9)", Replacement:="VirtualTab()", LookAt:=xlPart, MatchCase:=False

End If

Set rng = Nothing

End Sub