Prevent conversion to date format

R

Robert Lipman

Hi,

In VBA, how can I set a cell to '1-0' without it being converted to
date format such as Jan-00? I don't want a macro either. I'm
actually generating Excel spreadsheets with Tcl and not VBA, but the
VBA answer should suffice.

Thanks,

Bob
 
P

Peter T

Manually, you said you don't want a macro

Select cells and Numberformat (ctrl-1)
Apply the 'Text' item, or type a @ in Custom

or with code
rng.Numberformat = "@"

Regards,
Peter T
 
R

Robert Lipman

Manually, you said you don't want a macro

Select cells and Numberformat (ctrl-1)
Apply the 'Text' item, or type a @ in Custom

or with code
rng.Numberformat = "@"

Regards,
Peter T


Thanks, but I need to do it in VBA, not manually either.

Bob
 
K

Kevin B

Prefacing the entry with an apostrophe makes it a label and the following
snippet inserts the entry in the currently active cell:

Application.ActiveCell.Value = "'1-0"
 
P

Peter T

Robert Lipman said:
Thanks, but I need to do it in VBA, not manually either.

Bob

I'm confused, you said you don't want a macro so I showed how to do it
manually, but also I posted the equivalent VBA code.

Regards,
Peter T
 

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