Entering Text

  • Thread starter Thread starter Steve Etter
  • Start date Start date
S

Steve Etter

Hi. I am using an Excel spreadsheet as a "database" for
an older program. This program looks for the ' character
inside a cell to tell it that the data therein is "text"
otherwise it assumes the data is suppose to be a number.
Obviously I can enter my data by typing the ' character
manually, but is it possible to have Excel enter this
character automatically?

Thanks
Steve
 
This might work and it's the easiest.

Tools|Options|Transition Tab
Check the Transition Navigation keys.

Select a text cell and look at the formula bar. You should see that single
quote.

This is a hold over from Lotus 123. (I don't like this and would change it back
as soon as I was done processing that workbook.)

But you could also add that single quote to the text constants within the
selection via a macro:

Option Explicit
Sub testme02()

Dim myCell As Range
Dim myRng As Range

Set myRng = Selection 'activesheet.usedrange????

On Error Resume Next
Set myRng = Intersect(myRng, _
myRng.Cells.SpecialCells(xlCellTypeConstants, xlTextValues))
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "no Text cells found"
Exit Sub
End If

For Each myCell In myRng.Cells
If myCell.PrefixCharacter = "'" Then
'do nothing--it's already ok.
Else
myCell.Value = "'" & myCell.Value
End If
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top