Using Forms and Numbers

kjhoult

New Member
Joined
Nov 12, 2009
Messages
8
please help I have created using VB a simple form, that should put data from the form into the worksheet as a qty.

The data is copying across to the worksheet correctly, but is storing the data as text, then i cant find a way of converting this to a number, is there something im missing?

example of code

Range("millage") = millage
Range("qty_1") = qty1
Range("qty_2") = qty2
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Welcome to the Board!

Where is the rest of the code? Do you declare the variables? What kind of numbers will these be (i.e. integers, whole numbers, decimals)?

Code:
Range("millage") = clng(millage)
Range("qty_1") = clng(qty1)
Range("qty_2") = clng(qty2)
See if that helps? You may also have to look into using numberformat.

Hope that helps.
 
Upvote 0
Thanks Guys

Basically the form adds the number to the worksheet, then moves to the place in the spreadsheet where i need it, which moves everytime.


Private Sub OK_Click()

Range("Date1") = today
Range("name1") = text1
Range("millage") = millage
Range("qty_1") = qty1
Range("qty_2") = qty2
Range("qty_3") = qty3
Range("qty_4") = qty4
Range("qty_5") = qty5
Range("qty_6") = qty6
Range("qty_7") = qty7
Range("qty_8") = qty8
Range("qty_9") = qty9
Range("qty_10") = qty10

Range("code1") = combox1
Range("code2") = combox2
Range("code3") = combox3
Range("code4") = combox4
Range("code5") = combox5
Range("code6") = combox6
Range("code7") = combox7
Range("code8") = combox8
Range("code9") = combox9
Range("code10") = combox10


'Date

Range("Fj2").Select
Selection.Copy
Range("b19").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste

'Name

Range("FI2").Select
Selection.Copy
Range("b19").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 2).Select
ActiveSheet.Paste

'millage

Range("ge2").Select
Selection.Copy
Range("b19").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 14).Select
ActiveSheet.Paste


'code1

Range("Fk2").Select
Selection.Copy
Range("b19").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 4).Select
ActiveSheet.Paste

'qty1

Range("Fl2").Select
Selection.Copy
Range("b19").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 8).Select
ActiveSheet.Paste

If qty_2 >= 1 Then GoTo 2 Else GoTo 9999

2
then repeated, until end
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,482
Members
452,915
Latest member
hannnahheileen

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