Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Modify code to Add ComboBoxes instaed of Textbox values on Userform ?

Was:
Sub AddTxBxs() ' This Code Worked great for Textboxes
Dim TxBx As Control
Const T As String = "TextBox"
Dim sng122Total As Single
For Each TxBx In UserForm11.Controls
Select Case TxBx.Name
Case T & 62, T & 63, T & 66, T & 64, T & 65, T & 66, T & 67, T & 68, T & 69,
T & 70, T & 71
If IsNumeric(TxBx.Text) Then
sng122Total = sng122Total + TxBx.Text
End If
End Select
Next TxBx
UserForm11.TextBox122.Text = sng122Total
end sub

I have changed the Textboxes not to Comboboxes,
So i change the above to :
Sub AddCmbs() " This Code Does Not Add the Comboboxes
Dim ComboBox As Control
Const cmb As String = "ComboBox"
Dim sng122Total As Single
For Each cmb In UserForm11.Controls
Select Case cmb.Name
Case cmb & 23, cmb & 24, cmb & 25, cmb & 26, cmb & 27, cmb & 28, cmb & 29,
cmb & 30, cmb & 31, cmb & 32
If IsNumeric(cmb.Text) Then
sng122Total = sng122Total + cmb.Text
End If
End Select
Next cmb
UserForm11.TextBox122.Text = sng122Total
end sub

Can someone let me know why and/or how to get it to work ?

Corey....




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Modify code to Add ComboBoxes instaed of Textbox values on Userform ?

Look at the original code and how it has two different variables T and TxBx.
Now, contrast that with your code and how even though you declare two
different variables you use only one.

At a minimum you have to fix that. Of course, fixing the above may not
solve your problem since you haven't even stated what you want the code to
do. ;-)

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Was:
Sub AddTxBxs() ' This Code Worked great for Textboxes
Dim TxBx As Control
Const T As String = "TextBox"
Dim sng122Total As Single
For Each TxBx In UserForm11.Controls
Select Case TxBx.Name
Case T & 62, T & 63, T & 66, T & 64, T & 65, T & 66, T & 67, T & 68, T & 69,
T & 70, T & 71
If IsNumeric(TxBx.Text) Then
sng122Total = sng122Total + TxBx.Text
End If
End Select
Next TxBx
UserForm11.TextBox122.Text = sng122Total
end sub

I have changed the Textboxes not to Comboboxes,
So i change the above to :
Sub AddCmbs() " This Code Does Not Add the Comboboxes
Dim ComboBox As Control
Const cmb As String = "ComboBox"
Dim sng122Total As Single
For Each cmb In UserForm11.Controls
Select Case cmb.Name
Case cmb & 23, cmb & 24, cmb & 25, cmb & 26, cmb & 27, cmb & 28, cmb & 29,
cmb & 30, cmb & 31, cmb & 32
If IsNumeric(cmb.Text) Then
sng122Total = sng122Total + cmb.Text
End If
End Select
Next cmb
UserForm11.TextBox122.Text = sng122Total
end sub

Can someone let me know why and/or how to get it to work ?

Corey....





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Modify code to Add ComboBoxes instaed of Textbox values on Userform ?

Change cmb to ComboBox in at least these lines:

For Each cmb In UserForm11.Controls
Select Case cmb.Name
If IsNumeric(cmb.Text) Then
sng122Total = sng122Total + cmb.Text

Also, you shouldn't use existing keywords ("ComboBox") as variable names.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Tushar Mehta" wrote in message
om...
Look at the original code and how it has two different variables T and
TxBx.
Now, contrast that with your code and how even though you declare two
different variables you use only one.

At a minimum you have to fix that. Of course, fixing the above may not
solve your problem since you haven't even stated what you want the code to
do. ;-)

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Was:
Sub AddTxBxs() ' This Code Worked great for Textboxes
Dim TxBx As Control
Const T As String = "TextBox"
Dim sng122Total As Single
For Each TxBx In UserForm11.Controls
Select Case TxBx.Name
Case T & 62, T & 63, T & 66, T & 64, T & 65, T & 66, T & 67, T & 68, T &
69,
T & 70, T & 71
If IsNumeric(TxBx.Text) Then
sng122Total = sng122Total + TxBx.Text
End If
End Select
Next TxBx
UserForm11.TextBox122.Text = sng122Total
end sub

I have changed the Textboxes not to Comboboxes,
So i change the above to :
Sub AddCmbs() " This Code Does Not Add the Comboboxes
Dim ComboBox As Control
Const cmb As String = "ComboBox"
Dim sng122Total As Single
For Each cmb In UserForm11.Controls
Select Case cmb.Name
Case cmb & 23, cmb & 24, cmb & 25, cmb & 26, cmb & 27, cmb & 28, cmb &
29,
cmb & 30, cmb & 31, cmb & 32
If IsNumeric(cmb.Text) Then
sng122Total = sng122Total + cmb.Text
End If
End Select
Next cmb
UserForm11.TextBox122.Text = sng122Total
end sub

Can someone let me know why and/or how to get it to work ?

Corey....







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
Printing text from a textbox in a userform using vba code Zigball Excel Programming 4 November 2nd 06 03:34 PM
Help with UserForm textbox code excelnut1954 Excel Programming 1 January 9th 06 10:22 PM
Help with UserForm textbox code excelnut1954 Excel Programming 3 January 9th 06 09:34 PM
Adding TextBox to UserForm via code krzychu58 Excel Programming 1 September 24th 04 03:24 PM
Adding up values of textbox in Userform Mark Excel Programming 3 April 25th 04 09:10 PM


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

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"