Userforms - Dealing with zeros and non-entry of data

T

TroyB

Hi,

I have a userform where the user enters the percentage complete of various
items. I have a problem dealing with both of the following;
1) When activated, the userform extracts the previous "percent complete"
from the spreadsheet. If the user tabs over the previous number (doesn't
change the value) i get a zero or error message.
2) Because the number entered by the user is divided by 100, if the
"percent complete" is zero, i get a error (but i need the program to accept
zeros as an imput).

I'm currently using the following code for transferring the userform inputs
into the spreadsheet.
Range("PrelimDes").Value = Format((txtPrelimDesComplete.Value / 100),
"#0%")

What code could i use to alleviate my problems? Also, I havent defined my
userform variables. What is an appropriate dim for "percentage" values in
userform textboxes?

Thanks for your help
Troy
 
V

Vasant Nanavati

Try:

If IsNumeric(TextBox1) Then
Range("A1").NumberFormat = "#0%"
Range("A1").Value = TextBox1 / 100
End If
 
T

TroyB

Thank you Vasant. The code works great.
These newsgroups are excellent!

Regards,
Troy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top