Format from Row Source

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

Guest

Hi All

We use a fair few numbers with a leading zero - enters OK in a UserForm
textbox Tb1, however it always drops it on entering the cell on the sheet. Is
there anyway to retain the format of a leading zero. The code for the row
source is below.

Range(Me.Lb1.RowSource).Resize(1, 1).Offset(Me.Lb1.ListIndex, 3) =
Me.Tb1.Value
 
You could format that cell as text, then plop the value into it:

with Range(Me.Lb1.RowSource).Resize(1, 1).Offset(Me.Lb1.ListIndex, 3)
.numberformat = "@"
.value = Me.Tb1.Value
end with

Or you could prefix the value with an apostrophe:

Range(Me.Lb1.RowSource).Resize(1, 1).Offset(Me.Lb1.ListIndex, 3).value _
= "'" & me.Tb1.Value
 

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