Change format of a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having problems formatting a cell when sending a value from a textbox. Here is a part of what is being done
A User will enter a series of numbers into a textbox. When they exit the textbox, the value is reformate

'Add dashes when exiting textbo
MRN_TxBx.Value = Format(MRN_TxBx.Value, "#00-00-00"

If the user decides to re-enter the textbox, it removes the dashes to avoid any confusio

'Remove all dashes when entering textbo
MRN_TxBx.Value = Replace(MRN_TxBx.Value, "-", ""

When all is done, I copy the value to a cell with the following

'Format cell & add valu
.Cells(NxtRow, 1).NumberFormat = "General
.Cells(NxtRow, 1) = Data_Frm.MRN_TxBx.Valu

When I check the cell with the value, the format of the cell is always a date. I don't want a date format, I need it to be general or text. Any ideas

Thanks...
 
.Cells(NxtRow, 1).NumberFormat = "General"
.Cells(NxtRow, 1) = "'" & Data_Frm.MRN_TxBx.Value

--
Regards,
Tom Ogilvy


Troy said:
I am having problems formatting a cell when sending a value from a
textbox. Here is a part of what is being done.
A User will enter a series of numbers into a textbox. When they exit the
textbox, the value is reformated
'Add dashes when exiting textbox
MRN_TxBx.Value = Format(MRN_TxBx.Value, "#00-00-00")

If the user decides to re-enter the textbox, it removes the dashes to avoid any confusion

'Remove all dashes when entering textbox
MRN_TxBx.Value = Replace(MRN_TxBx.Value, "-", "")

When all is done, I copy the value to a cell with the following:

'Format cell & add value
.Cells(NxtRow, 1).NumberFormat = "General"
.Cells(NxtRow, 1) = Data_Frm.MRN_TxBx.Value

When I check the cell with the value, the format of the cell is always a
date. I don't want a date format, I need it to be general or text. Any
ideas?
 
Troy,

Horrible, but ...

'Format cell & add value
.Cells(nxtrow, 1).NumberFormat = "General"
.Cells(nxtrow, 1) = "'" & Data_Frm.MRN_TxBx.Text

---

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Troy said:
I am having problems formatting a cell when sending a value from a
textbox. Here is a part of what is being done.
A User will enter a series of numbers into a textbox. When they exit the
textbox, the value is reformated
'Add dashes when exiting textbox
MRN_TxBx.Value = Format(MRN_TxBx.Value, "#00-00-00")

If the user decides to re-enter the textbox, it removes the dashes to avoid any confusion

'Remove all dashes when entering textbox
MRN_TxBx.Value = Replace(MRN_TxBx.Value, "-", "")

When all is done, I copy the value to a cell with the following:

'Format cell & add value
.Cells(NxtRow, 1).NumberFormat = "General"
.Cells(NxtRow, 1) = Data_Frm.MRN_TxBx.Value

When I check the cell with the value, the format of the cell is always a
date. I don't want a date format, I need it to be general or text. Any
ideas?
 

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

Back
Top