Number Value Put Into Cell Not Accepting Format

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am trying to put a number value converted from a text value (Me.empl_no2.Value) into a cell with the format of "00000" with this line of code ...

Code:
.Cells(lr_orp, 22) = Format(CLng(Me.empl_no2.Value), "00000")

All I am getting in the cell is '0', not '00000'.

Where have I gone wrong.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
It don't understand your value is Text. For, you need Format Cells to Text.

Code:
'Case 1:
.Cells(lr_orp, 22).NumberFormat = "000000"
.Cells(lr_orp, 22) = Format(CLng(Me.empl_no2.Value), "00000")

'Case 2:
.Cells(lr_orp, 22) = "'" & Format(CLng(Me.empl_no2.Value), "00000")
 
Upvote 0
Try this:

Code:
With .Cells(lr_orp, 22)
    .Value = Me.empl_no2.Value
    .NumberFormat = "00000"
End With

Regards,

Robert
 
Last edited:
Upvote 0
Yep! That was what I was looking for. Thank you.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top