Hi, I'm looking for a way to convert the textbox value so that if I put for example 5 in the textbox it will appear as 5% in the cell.
I wrote the code in this way:
But I kept getting a Type mismatch error, and after going through google, I think I have to make the TextBox6, 8, and 10 to Integer so that the = Formatting code can work.
Can anybody point out what's wrong and correct my code?? I tried many things, but kept getting error every time.
Cheers,
I wrote the code in this way:
Code:
Private Sub UserForm_Initialize()
TextBox6.Value = Format(Me.TextBox6.Value / 100, "Percent")
TextBox8.Value = Format(Me.TextBox8.Value / 100, "Percent")
TextBox10.Value = Format(Me.TextBox10.Value / 100, "Percent")
End Sub
[U]_________________________________________________________[/U]
Private Sub cmdAdd_Click()
If MsgBox("Do you want to input the data?", vbYesNo) = vbYes Then
Dim lrow As Long
Dim ws As Worksheet
Set ws = Worksheets("RawData")
lrow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws[INDENT].Cells(lrow, 13).Value = Me.TextBox6.Value
.Cells(lrow, 15).Value = Me.TextBox8.Value
.Cells(lrow, 17).Value = Me.TextBox10.Value[/INDENT]
End With
[INDENT]Me.TextBox6.Value = ""
Me.TextBox8.Value = ""
Me.TextBox10.Value = ""[/INDENT]
Else
End If
End Sub
But I kept getting a Type mismatch error, and after going through google, I think I have to make the TextBox6, 8, and 10 to Integer so that the = Formatting code can work.
Can anybody point out what's wrong and correct my code?? I tried many things, but kept getting error every time.
Cheers,