ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change format of a cell (https://www.excelbanter.com/excel-programming/291532-change-format-cell.html)

Troy[_3_]

Change format of a cell
 
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...

Tom Ogilvy

Change format of a cell
 
.Cells(NxtRow, 1).NumberFormat = "General"
.Cells(NxtRow, 1) = "'" & Data_Frm.MRN_TxBx.Value

--
Regards,
Tom Ogilvy


"Troy" wrote in message
...
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?

Thanks...




Bob Phillips[_6_]

Change format of a cell
 
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" wrote in message
...
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?

Thanks...




Troy[_3_]

Change format of a cell
 
That worked! Thanks a bunch!!

Troy[_3_]

Change format of a cell
 
That worked! Thanks a bunch!!


All times are GMT +1. The time now is 07:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com