![]() |
Userforms - Dealing with zeros and non-entry of data
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 |
Userforms - Dealing with zeros and non-entry of data
Try:
If IsNumeric(TextBox1) Then Range("A1").NumberFormat = "#0%" Range("A1").Value = TextBox1 / 100 End If -- Vasant "TroyB" wrote in message u... 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 |
Userforms - Dealing with zeros and non-entry of data
Thank you Vasant. The code works great.
These newsgroups are excellent! Regards, Troy "Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... Try: If IsNumeric(TextBox1) Then Range("A1").NumberFormat = "#0%" Range("A1").Value = TextBox1 / 100 End If -- Vasant "TroyB" wrote in message u... 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 |
All times are GMT +1. The time now is 08:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com