Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 2 Textbox questions

1. Textbox Number Format

Based on a combobox selection a textbox is filled as shown below:

Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub

The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).

How can I get the textbox to display what is shown on the worksheet
(5.1 or 5.10)?

2. Deleting Value from Textbox

The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent of of
defect.

Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 / 4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub

When entering a value into the textbox(txtDefectLength) it works fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"

What can I do to stop this from happening?

Any help would be appreciated.

Kind Regards
Martin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 2 Textbox questions

1. txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2).Text

2. Add a command button, and calculate upon clicking the button rather than
textbox change. The problem with textbox change is that it fires for every
change to the textbox, not just when done. You could also experiment with
the textbox Exit, or AfterUpdate events.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
1. Textbox Number Format

Based on a combobox selection a textbox is filled as shown below:

Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub

The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).

How can I get the textbox to display what is shown on the worksheet
(5.1 or 5.10)?

2. Deleting Value from Textbox

The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent of of
defect.

Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 / 4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub

When entering a value into the textbox(txtDefectLength) it works fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"

What can I do to stop this from happening?

Any help would be appreciated.

Kind Regards
Martin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 2 Textbox questions

Bob,
Just wanted to say thanks for your help.
Kind Regards
Martin

"Bob Phillips" wrote in message ...
1. txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2).Text

2. Add a command button, and calculate upon clicking the button rather than
textbox change. The problem with textbox change is that it fires for every
change to the textbox, not just when done. You could also experiment with
the textbox Exit, or AfterUpdate events.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
1. Textbox Number Format

Based on a combobox selection a textbox is filled as shown below:

Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub

The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).

How can I get the textbox to display what is shown on the worksheet
(5.1 or 5.10)?

2. Deleting Value from Textbox

The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent of of
defect.

Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 / 4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub

When entering a value into the textbox(txtDefectLength) it works fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"

What can I do to stop this from happening?

Any help would be appreciated.

Kind Regards
Martin

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 2 Textbox questions

It's a pleasure Martin.

What did you go with on point 2 in the end?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
Bob,
Just wanted to say thanks for your help.
Kind Regards
Martin

"Bob Phillips" wrote in message

...
1. txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2).Text

2. Add a command button, and calculate upon clicking the button rather

than
textbox change. The problem with textbox change is that it fires for

every
change to the textbox, not just when done. You could also experiment

with
the textbox Exit, or AfterUpdate events.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
1. Textbox Number Format

Based on a combobox selection a textbox is filled as shown below:

Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub

The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).

How can I get the textbox to display what is shown on the worksheet
(5.1 or 5.10)?

2. Deleting Value from Textbox

The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent of of
defect.

Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 / 4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub

When entering a value into the textbox(txtDefectLength) it works fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"

What can I do to stop this from happening?

Any help would be appreciated.

Kind Regards
Martin



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 2 Textbox questions

Hi Bob,

Probably not the most elegant solution, I just moved the Code to
Afterupdate, but it works.

Martin

"Bob Phillips" wrote in message ...
It's a pleasure Martin.

What did you go with on point 2 in the end?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
Bob,
Just wanted to say thanks for your help.
Kind Regards
Martin

"Bob Phillips" wrote in message

...
1. txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2).Text

2. Add a command button, and calculate upon clicking the button rather

than
textbox change. The problem with textbox change is that it fires for

every
change to the textbox, not just when done. You could also experiment

with
the textbox Exit, or AfterUpdate events.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
1. Textbox Number Format

Based on a combobox selection a textbox is filled as shown below:

Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub

The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).

How can I get the textbox to display what is shown on the worksheet
(5.1 or 5.10)?

2. Deleting Value from Textbox

The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent of of
defect.

Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 / 4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub

When entering a value into the textbox(txtDefectLength) it works fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"

What can I do to stop this from happening?

Any help would be appreciated.

Kind Regards
Martin



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 2 Textbox questions

Thanks for letting me know.

AfterUpdate is good, it's an oft overlooked event.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
Hi Bob,

Probably not the most elegant solution, I just moved the Code to
Afterupdate, but it works.

Martin

"Bob Phillips" wrote in message

...
It's a pleasure Martin.

What did you go with on point 2 in the end?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
Bob,
Just wanted to say thanks for your help.
Kind Regards
Martin

"Bob Phillips" wrote in message

...
1. txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2).Text

2. Add a command button, and calculate upon clicking the button

rather
than
textbox change. The problem with textbox change is that it fires for

every
change to the textbox, not just when done. You could also experiment

with
the textbox Exit, or AfterUpdate events.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Martin Koenig" wrote in message
om...
1. Textbox Number Format

Based on a combobox selection a textbox is filled as shown below:

Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub

The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).

How can I get the textbox to display what is shown on the

worksheet
(5.1 or 5.10)?

2. Deleting Value from Textbox

The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent

of of
defect.

Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 /

4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub

When entering a value into the textbox(txtDefectLength) it works

fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"

What can I do to stop this from happening?

Any help would be appreciated.

Kind Regards
Martin



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
Answers to questions posing more questions in a workbook sbelle1 Excel Worksheet Functions 2 August 8th 09 01:02 AM
Calculate Textbox value based on another textbox value.doc Tdungate Excel Discussion (Misc queries) 1 February 12th 09 07:11 PM
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 02:04 AM.

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

About Us

"It's about Microsoft Excel"