Completely stumped with number formatting

Lectricman

New Member
Joined
Feb 18, 2016
Messages
14
Long time no see.
I am having a nightmare trying to get data from a textbox to a cell in a number format.
I have tried just about every tip and trick on the net and either my vba is wrong or I'm being a bit dense.

Code:
With Worksheets(SheetName)
    
        .Cells(iRow, 1).Value = Me.txtWhen.Value
        .Cells(iRow, 4).Value = txtShift1
        .Cells(iRow, 2).Value = Me.txtLocation.Value
        .Cells(iRow, 3).Value = txtOperator
        .Cells(iRow, 5).Value = txtOrders
        .Cells(iRow, 6).Value = txtWhat1
        .Cells(iRow, 7).Value = txtQuantity1
        .Cells(iRow, 7).NumberFormat = "#,##0"
        .Cells(iRow, 8).Value = cbUnits1
        .Cells(iRow, 9).Value = txtComment
     
       End With

I have several combo and text boxes on a user form and only one of them needs to be in a number format.
So how do I get the data from txtQuantity1 into a cell in a usable number format. Once all the data is entered the user presses a button and the data is transfered to a worksheet and the form is cleared ready to be used again. Everthing works fine and dandy apart from the formatting of txtQuantity1.

Many, many thanks in advance.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You need to convert the value from text to numeric like
Code:
.Cells(iRow, 7).Value = Val(txtQuantity1)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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