Userform/Cell formatting

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

I had to change the offsets from 0, 0 to 1, 0 and it
worked perfectly. But what is the code I would use if I
wanted it set up like I had before (see below)....

like this:
Worksheets("Pay Calculator").Range("AA1").Value =
TextBox1.Value

and when I type a number in one of the textboxes, it
automatically adds a % on it and shows that % while in the
text box.

Also the userform1.hide code at the end doesnt actually
close the userform. What is the code I would use to have
it unload the form so next time I open it up, the changes
are automatically reflected.


Thanx.

Private Sub CommandButton2_Click()
Dim i As Long, sStr As String
With Worksheets("Pay Calculator").Range("AA1")
For i = 1 To 4
sStr = Me.Controls("TextBox" & i).Value
If InStr(sStr, "%") Then
.Offset(i - 1, 0).Value = sStr
Else
.Offset(i - 1, 0).Value = CDbl(sStr) / 100
End If
Next
End With
UserForm1.Hide
End Sub
 
Thank you. I was doing userform1.unload. I wondered why
it wasnt working.

Thanx again.
 
Back
Top