Question

en.orrset (0, g).value = Me.chkIN.Value End If clear form End Sub Private Sub UserForm Initialize() Dim i As Long, LastRow A

Private Sub cboEmp_Change () Dim i As Long, LastRow As Long, LastR As Long, ws As Worksheet Set ws - Worksheets (TOOLS EMP E

Created a userform,but I'm having an issue with one part. I created a few combo boxes and when a user selects data from those combo boxes it should Auto populate information that I have stored on a separate Excel sheet into some text boxes that I added next to the combo boxes .
One of the combo boxes (cboEmp) is doing excatly what I want it to do,but the other combo box (cboGageNum) is not working properly.
I used the same format as the combo box that is working, so not sure what it's not correctly populating the data that I need into the text box. So when I select something from the combo box (cboGageNum) it pulls the data that I need and trasfers it into the combo box,but it won't pull the data that needs to go into the text box (should Autofill on it's own) (txtTool), and sometimes it doesn't pull anything. Is there a reason why it's doing this and is there a solution? Like I said, for the combo box (cboEmp) and the text box associated with that, everything works perfect there.

Also, what code can I use to have the form save on it's own once data is submitted when using the form?

Thank you in advance.

en.orrset (0, g).value = Me.chkIN.Value End If 'clear form End Sub Private Sub UserForm Initialize() Dim i As Long, LastRow As Long, LastR As Long, ws As Worksheet Dim y As Long Set ws = Worksheets ("TOOLS-EMP-EMP # ") LastRow = ws . Range ("A" & Rows.Count).End(x1Up).Row LastR ws.Range ("G" & Rows.Count) .End (xlUp) . Row this is for empnumber For i = 2 To LastRow "A"). Value Me.cboEmp.AddItem ws. Cells (ǐ, Next i this is for gagedescribtion For y = 2 To LastR Me.cboGageNum.AddItem ws.Cells (y, "G"). Value Nexty atches Value
Private Sub cboEmp_Change () Dim i As Long, LastRow As Long, LastR As Long, ws As Worksheet Set ws - Worksheets ("TOOLS EMP EMP#") "LastR = ws .Range ("H" & Rows.count) .End (x1Up) .Row LastRow = ws . Range ("A" & Rows .count)·End (x10p).Row 'this is for empname For i = 2 To LastRow If Val (Me.cboEmp.Value) -ws.Cells (i, "A") Then MsgBox Me.cboEmp.Value Me.txtName =ws.cells (i, "B").value End If Next i End Sub Private Sub cboGageNum Change () Dim y As Long, LastRow As Long, LastR As Long, ws As Worksheet Set ws Worksheets ("TOOLS EMP-EMP#") LastR ws.Range ("G"&Rows. Count).End (xlUp) . Row 'this is for gagedescription For y 2 To LastR If Val (Me.cboGageNum. Value) ws.Cells (y, "G") Then "MsgBox Me.cboGageNum. Value Me.txtToo! = ws. Cells (у, "н") .Value End If Next y End Sub
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Try this code. If the worksheet name doesn't exist then the code will create it.

Sub Copy_Data()
Dim r As Range, LastRow As Long, ws As Worksheet
Dim c As Range, s As String, LastRow1 As Long
Dim src As Worksheet, MyRange As Range
Dim LastRow3 As Long
Set src = Sheets("Sheet3")
LastRow = Sheets("Sheet2").Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Sheets("Sheet2").Range("A2:A" & LastRow)
LastRow3 = src.Cells(Cells.Rows.Count, "B").End(xlUp).Row
For Each c In MyRange

For Each r In src.Range("B2:B" & LastRow3)
     If UCase(r.Value) = UCase(c.Value) Then
         On Error Resume Next
         Set ws = Sheets(CStr(r.Value))
         On Error GoTo 0
         If ws Is Nothing Then
             Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = CStr(r.Value)
             LastRow1 = Sheets(CStr(r.Value)).Cells(Cells.Rows.Count, "B").End(xlUp).Row
             src.Rows(r.Row).Copy Sheets(CStr(r.Value)).Cells(LastRow1 + 1, 1)
             Set ws = Nothing
         Else
             LastRow1 = Sheets(CStr(r.Value)).Cells(Cells.Rows.Count, "B").End(xlUp).Row
             src.Rows(r.Row).Copy Sheets(CStr(r.Value)).Cells(LastRow1 + 1, 1)
             Set ws = Nothing
         End If
     End If
Next r

Next c
End Sub

Add a comment
Know the answer?
Add Answer to:
Created a userform,but I'm having an issue with one part. I created a few combo boxes and when a user select...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this exercise, you’ll add code to a form that converts the value the user enters...

    In this exercise, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: 1. Open the Conversions project. Display the code for the form, and notice the rectangular array whose rows contain the value to be displayed in the combo box, the text for the labels that identify the two text boxes, and the multiplier for the conversion as shown above. Note: An array...

  • Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the valu...

    Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...

  • JAVA JAR HELP...ASAP I have the code that i need for my game Connect 4, but...

    JAVA JAR HELP...ASAP I have the code that i need for my game Connect 4, but i need to create a jar file . the instructions are below. It has to pass some parameters. I am really confused on doing so.l I dont know what to do next. Can someone help me and give detailed descritiopm opn how you ran the jar file in CMD import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Connect4 {               ...

  • Hello, I have some errors in my C++ code when I try to debug it. I...

    Hello, I have some errors in my C++ code when I try to debug it. I tried to follow the requirements stated below: Code: // Linked.h #ifndef INTLINKEDQUEUE #define INTLINKEDQUEUE #include <iostream> usingnamespace std; class IntLinkedQueue { private: struct Node { int data; Node *next; }; Node *front; // -> first item Node *rear; // -> last item Node *p; // traversal position Node *pp ; // previous position int size; // number of elements in the queue public: IntLinkedQueue();...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • EX16_XL_CH05_GRADER_CAP_AS - Travel Expenses 1.8 Project Description: <Project Description> Steps to Perform: Step Instructions Points Possible...

    EX16_XL_CH05_GRADER_CAP_AS - Travel Expenses 1.8 Project Description: <Project Description> Steps to Perform: Step Instructions Points Possible 1 Start Excel. Open the downloaded Excel file named exploring_e05_grader_a1_Expenses.xlsx. Save the workbook as exploring_e05_grader_a1_Expenses_LastFirst, replacing LastFirstwith your own name. 0 2 On the Subtotals worksheet, use the Sort dialog box to sort the data by Employee and further sort by Category, both in alphabetical order. 4 3 Use the Subtotals feature to insert subtotal rows by Employee to calculate the total expense by...

  • Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be...

    Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...

  • Don't attempt if you can't attempt fully, i will dislike and negative comments would be given...

    Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...

  • Home Insert Draw Page Layout Formulas Data Review View percentage 29 ES 2 Calibri (Body) 12...

    Home Insert Draw Page Layout Formulas Data Review View percentage 29 ES 2 Calibri (Body) 12 A A * BLUE OA 13 Conditional Formatting Format as Table Cell Styles 2 Insert Delete Format 5 % + Recover Unsaved Workbooks. We were able to save changes to one or more files. Do you want to recover them? X f x -'BS V&H'ID47 E4 Effective management of assets is critical for most companies. Investment in assets is needed to drive revenue growth....

  • Develop a case study analysis in the following format Relevance of the case study to my...

    Develop a case study analysis in the following format Relevance of the case study to my work environment - application - learning impact CASE 4-1 Tambrands Overcoming Cultural Resistance Tampax, Tambrands's only product, is the best-selling tampon in their virginity if they use a tampon. When they go to the beach in the world, with 44 pencent of the global market North America and tiny bikinis, tampons arent their choike. Instead, hordes of women Europe account for 90 percent of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT