F
Fred
Hi
I need to limit the number of characters used in a cell to 3 digits. I have
an input box for data entry.
The result I get for len(cpacode) is 2, irregardless of the number of digits
I use. Len returns the number of bytes for the variable because I declared
it to be an Integer.
If I declare the variable as a string, text characters can then be entered
into the variable. I need the variable to only contain numbers. How do I do
this?
Dim CPACode As Integer
CPACode = InputBox("Please enter in the new value for the CPA Code.")
'Get the new value for the CPA Code
Do Until Len(CPACode) = 3 'If the CPA Code is not 10
characters long, get the value again
CPACode = InputBox("The length of the CPA Code must be 3 characters.
Please make sure that you have the correct CPA Code.") 'Get the correct
value for the CPA Code
Loop 'End loop
If Len(CPACode) = 3 Then 'If the length of the CPA
Code is 3 characters long
Range("B5").Value = CPACode 'Put the new value for CPA
Code in cell B5
End If 'End the test
Thanks
Fred
I need to limit the number of characters used in a cell to 3 digits. I have
an input box for data entry.
The result I get for len(cpacode) is 2, irregardless of the number of digits
I use. Len returns the number of bytes for the variable because I declared
it to be an Integer.
If I declare the variable as a string, text characters can then be entered
into the variable. I need the variable to only contain numbers. How do I do
this?
Dim CPACode As Integer
CPACode = InputBox("Please enter in the new value for the CPA Code.")
'Get the new value for the CPA Code
Do Until Len(CPACode) = 3 'If the CPA Code is not 10
characters long, get the value again
CPACode = InputBox("The length of the CPA Code must be 3 characters.
Please make sure that you have the correct CPA Code.") 'Get the correct
value for the CPA Code
Loop 'End loop
If Len(CPACode) = 3 Then 'If the length of the CPA
Code is 3 characters long
Range("B5").Value = CPACode 'Put the new value for CPA
Code in cell B5
End If 'End the test
Thanks
Fred