UserForm to replace working code

BasicUserWithExp

New Member
Joined
Feb 15, 2018
Messages
15
I have a bid form that works, but the code is cumbersome. I have a column of check boxes called "include", a column off the same called "Exclude", a column of items to be included or excluded, and column of notes for the item. After selecting the check boxes i have code that adds the selected items to 2 text boxes, after clearing them.

The problem is i want to be able to add rows to the sheet to breakdown some estimated values that customers request. If i add rows where i need to, it changes the value of the check box cell assignments, and i have to update the whole list.

I created a userform called IncExc and added check boxes and text boxes. but i am not knowledgeable enough with code to make it do what i want... HELP!

http://www.dropbox.com/s/gt5jkwktcmmm8ec/Quote Sheet 10-25-19---BLANK.xlsm?dl=0
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I never click on links on this site that take me to a Excel file.

So you said:
I have a bid form that works

A bid form ??

Do you mean a sheet named bid.

I'm not a advocate of using a lot of Textboxes or checkboxes on a sheet.
And the problem your having is one of the reasons.

So a UserForm is a good way to enter data on a sheet.

Please explain in detail what your attempting to do.

So say something like this:

I want to enter "John" into a UserForm TextBox and then when I click a button on my UserForm put John into active sheet TextBox Named "Employee"

Or something like that.

What do you want to do with the Userform CheckBoxes?

Tell me more about what you want to do and hopefully I can provide the code you need.

Be very specific with your details.
 
Upvote 0
Here is a very simple example of how you take values from a Userform Textbox and enter it into a Excel Worksheet Activex Textbox

Put this script into your Excel Userform Command Button.

Code:
Private Sub CommandButton1_Click()
'Modified  11/7/2019  3:22:43 AM  EST
Sheets(1).TextBox1.Value = TextBox1.Value
End Sub
 
Upvote 0
I apologize for not being more clear. Bid form refers to a workbook in excel. This is a change to the code on the proposal page.
I want a list of 20 items (or more) typed in column R & S to populate TextBox1(Excluded) based on checkbox1 to 20 or TextBox2(included based on checkbox21 to 40

this is the current code:
Code:
Private Sub CommandButton1_Click()


TextBox1.Text = ""


If CheckBox1.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R37").Value & " - " & Range("S37").Value & ", "
End If


If CheckBox2.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R38").Value & " - " & Range("S38").Value & ", "
End If


If CheckBox3.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R39").Value & " - " & Range("S39").Value & ", "
End If


If CheckBox4.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R40").Value & " - " & Range("S40").Value & ", "
End If


If CheckBox5.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R41").Value & " - " & Range("S41").Value & ", "
End If


If CheckBox6.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R42").Value & " - " & Range("S42").Value & ", "
End If


If CheckBox7.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R43").Value & " - " & Range("S43").Value & ", "
End If


If CheckBox8.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R44").Value & " - " & Range("S44").Value & ", "
End If


If CheckBox9.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R45").Value & " - " & Range("S45").Value & ", "
End If


If CheckBox10.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R46").Value & " - " & Range("S46").Value & ", "
End If


If CheckBox11.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R47").Value & " - " & Range("S47").Value & ", "
End If


If CheckBox12.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R48").Value & " - " & Range("S48").Value & ", "
End If


If CheckBox13.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R49").Value & " - " & Range("S49").Value & ", "
End If


If CheckBox14.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R50").Value & " - " & Range("S50").Value & ", "
End If


If CheckBox15.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R51").Value & " - " & Range("S51").Value & ", "
End If


If CheckBox16.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R52").Value & " - " & Range("S52").Value & ", "
End If


If CheckBox17.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R53").Value & " - " & Range("S53").Value & ", "
End If


If CheckBox18.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R54").Value & " - " & Range("S54").Value & ", "
End If


If CheckBox19.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R55").Value & " - " & Range("S55").Value & ", "
End If


If CheckBox20.Value = True Then
    TextBox1.Text = TextBox1.Text & Range("R56").Value & " - " & Range("S56").Value & ", "
End If




TextBox2.Text = ""


If CheckBox21.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R37").Value & " - " & Range("S37").Value & ", "
End If


If CheckBox22.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R38").Value & " - " & Range("S38").Value & ", "
End If


If CheckBox23.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R39").Value & " - " & Range("S39").Value & ", "
End If


If CheckBox24.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R40").Value & " - " & Range("S40").Value & ", "
End If


If CheckBox25.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R41").Value & " - " & Range("S41").Value & ", "
End If


If CheckBox26.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R42").Value & " - " & Range("S42").Value & ", "
End If


If CheckBox27.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R43").Value & " - " & Range("S43").Value & ", "
End If


If CheckBox28.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R44").Value & " - " & Range("S44").Value & ", "
End If


If CheckBox29.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R45").Value & " - " & Range("S45").Value & ", "
End If


If CheckBox30.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R46").Value & " - " & Range("S46").Value & ", "
End If


If CheckBox31.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R47").Value & " - " & Range("S47").Value & ", "
End If


If CheckBox32.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R48").Value & " - " & Range("S48").Value & ", "
End If


If CheckBox33.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R49").Value & " - " & Range("S49").Value & ", "
End If


If CheckBox34.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R50").Value & " - " & Range("S50").Value & ", "
End If


If CheckBox35.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R51").Value & " - " & Range("S51").Value & ", "
End If


If CheckBox36.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R52").Value & " - " & Range("S52").Value & ", "
End If


If CheckBox37.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R53").Value & " - " & Range("S53").Value & ", "
End If


If CheckBox38.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R54").Value & " - " & Range("S54").Value & ", "
End If


If CheckBox39.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R55").Value & " - " & Range("S55").Value & ", "
End If


If CheckBox40.Value = True Then
    TextBox2.Text = TextBox2.Text & Range("R56").Value & " - " & Range("S56").Value & ", "
End If
End Sub


Private Sub TextBox1_Change()
With TextBox1
    .AutoSize = True
    .MultiLine = True
    .WordWrap = True
    .TopLeftCell.RowHeight = TextBox1.Height
    .Width = 685 'Set as required
End With
End Sub


Private Sub TextBox2_Change()
With TextBox2
    .AutoSize = True
    .MultiLine = True
    .WordWrap = True
    .TopLeftCell.RowHeight = TextBox2.Height
    .Width = 685 'Set as required
End With
End Sub

I would like a userform to replace the code: if checkbox1 is selected, add text to textox1, if checkbox2 is selected add text to textbox2. for 20 or more items
INCEXC.JPG
form.JPG
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top