Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Keypress event???? data validation on a userform in vba for spread

I have a vba form I am using to have a user enter information into a
spreadsheet to do some calculations for me. One of the values is a length
value i.e. 164 and 3/8". What I am trying to accomplish is to have the user
not be able to enter a " mark in the textbox, because that value in my
spreadsheet breaks all of my formulas. My formulas just want a number, not
"text". The control I am using for them to enter into is a text box.
Someone said I should capture the kepress event and block it if it as a
quotation mark before writing the value to the field. So...I am struggling
with how to get this accomplished. Any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Keypress event???? data validation on a userform in vba for spread

Roundy,

I think this would work. I added the message to to reduce user
confusion/frustration:

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 34 Then
MsgBox "Sorry, no quotes (" & Chr(34) & ") allowed."
KeyAscii = 0
End If
End Sub

hth,

Doug


"Roundy" wrote in message
...
I have a vba form I am using to have a user enter information into a
spreadsheet to do some calculations for me. One of the values is a length
value i.e. 164 and 3/8". What I am trying to accomplish is to have the
user
not be able to enter a " mark in the textbox, because that value in my
spreadsheet breaks all of my formulas. My formulas just want a number,
not
"text". The control I am using for them to enter into is a text box.
Someone said I should capture the kepress event and block it if it as a
quotation mark before writing the value to the field. So...I am
struggling
with how to get this accomplished. Any help would be appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Keypress event???? data validation on a userform in vba for sp

Thank you so much for your response, it works great.

"Doug Glancy" wrote:

Roundy,

I think this would work. I added the message to to reduce user
confusion/frustration:

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 34 Then
MsgBox "Sorry, no quotes (" & Chr(34) & ") allowed."
KeyAscii = 0
End If
End Sub

hth,

Doug


"Roundy" wrote in message
...
I have a vba form I am using to have a user enter information into a
spreadsheet to do some calculations for me. One of the values is a length
value i.e. 164 and 3/8". What I am trying to accomplish is to have the
user
not be able to enter a " mark in the textbox, because that value in my
spreadsheet breaks all of my formulas. My formulas just want a number,
not
"text". The control I am using for them to enter into is a text box.
Someone said I should capture the kepress event and block it if it as a
quotation mark before writing the value to the field. So...I am
struggling
with how to get this accomplished. Any help would be appreciated.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
keypress event on a userform Peter[_21_] Excel Programming 2 July 11th 05 07:25 PM
Getting KeyPress Event to work Pete Excel Programming 2 November 9th 04 08:25 PM
Keypress Event R Avery Excel Programming 2 August 4th 04 03:51 PM
KeyPress Event Conrado Capistrano Excel Programming 4 September 25th 03 05:27 AM


All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"