Populating excel cells from a form formated as a number?

WolfLarsen85

New Member
Joined
Apr 25, 2016
Messages
17
Hello,
I am trying to create a form in excel and I am dropping values from the form into an excel cell. The problem I am having is that I can't get the values that drop into excel to format as numbers. Here is the code I have thus far. I set "txtBody" as an integer, but when I fill out the txtBody text box it still formats as general. Please help and let me know if anything else is needed.

Private Sub cmdEnter_Click()
Dim ws As Worksheet
Set ws = Worksheets("Dungeonslayers")
' Check user input

' Enter Data into Cell
Dim txtBody As Integer
ws.Cells(7, 3).Value = txtPlayer
ws.Cells(9, 3).Value = CmboRace
ws.Cells(11, 3).Value = txtAbilities
ws.Cells(8, 4).Value = cboLevel
ws.Cells(7, 7).Value = txtCharacter
ws.Cells(11, 7).Value = cboClass
ws.Cells(8, 5).Value = txtPP
ws.Cells(8, 6).Value = txtTP
ws.Cells(11, 5).Value = txtExperience
ws.Cells(11, 11).Value = cboHero
ws.Cells(13, 7).Value = txtMind
ws.Cells(15, 7).Value = txtIntellect
ws.Cells(17, 7).Value = txtAura
ws.Cells(13, 3).Value = txtBody
ws.Cells(15, 3).Value = txtStrength
ws.Cells(17, 3).Value = txtConstitution
ws.Cells(10, 9).Value = txtExperience
ws.Cells(13, 5).Value = txtMobility
ws.Cells(15, 5).Value = txtAgility
ws.Cells(17, 5).Value = txtDexterity
End Sub

Private Sub cmdExit_Click()
End
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This for an example only, note the bold portions dealing with numeric values

Howard

Code:
Private Sub CommandButton1_Click()
Dim Dest As Range

With Sheets("Master")
    Set Dest = .Cells(Rows.Count, 1).End(xlUp)(2)
    If Len(TextBox1) > 0 And Len(TextBox2) > 0 Then
    
        [B]'textbox or a combobox always contains text even if it is a number
        'To get a real number into the sheet you have to change it with CLng or CDbl or CInt
        'Numeric value???
        Dest = CLng(TextBox1.Value)[/B] 
        Dest.Offset(, 1) = TextBox2.Value
        Dest.Offset(, 2) = ComboBox1.Value
        Dest.Offset(, 3) = ComboBox2.Value
        Dest.Offset(, 4) = ComboBox3.Value
        Dest.Offset(, 5) = TextBox3.Value
        Dest.Offset(, 6) = TextBox4.Value
        Dest.Offset(, 7) = TextBox5.Value
        
[B]        'Numeric value???
        Dest.Offset(, 8) = CLng(TextBox6.Value)[/B]        
        Dest.Offset(, 9) = TextBox7.Value
        Dest.Offset(, 10) = TextBox8.Value
        Dest.Offset(, 11) = TextBox9.Value
    Else
        MsgBox "No entries for Name and Employee ID"
        Exit Sub
    End If
    Unload Me
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

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