Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am going crazy trying to work this out.
I have a shet that i am trying to populate with data from another sheet. I am using a userform to do this for some of the data. The userform is triggered from the event below :- ~~~~~~~~~ Userform.Show ~~~~~~~~~~~~~~~~~~~~ Private Sub Worksheet_SelectionChange(ByVal Target As Range) Application.ScreenUpdating = False With Sheet5 If Not Intersect(Target, Me.Range("A4:A13")) Is Nothing Then ActiveCell.Select Call UF11 End If End With Application.ScreenUpdating = True End Sub ~~~~~~~~~ End of Code ~~~~~~~~~~~~~~~~~~~~~~ When the user activates a cell in the above code range the Userform is displayed. The Userform has so far 2 comboboxes(Combobox1 & Combobox 2) : ~~~~~~~~~~~~~~~ Combobox1 Code ~~~~~~~~~~~~~ Private Sub ComboBox1_DropButtonClick() 'Application.ScreenUpdating = False If ComboBox1.ListCount 0 Then Exit Sub 'Place the References in here for the Roll Numbers and Lengths Dim lastcell As Long Dim myrow As Long On Error Resume Next lastcell = workSheets("InspectionData").Cells(Rows.Count, "A").End(xlUp).Row With ActiveWorkbook.workSheets("InspectionData") ..Select 'first thing to do with a With statement that occurs on a second sheet For myrow = 2 To lastcell If .Cells(myrow, 1) < "" Then If .Cells(myrow, 1).Offset(-1, 2).Text = Sheet5.Range("B2").Value And IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then ComboBox1.AddItem Cells(myrow, 1) End If End If Next End With End Sub ~~~~~~~~~~~~~~ End of Code ~~~~~~~~~~~~~~~~~~~ The ABOVE code lists ALL values in the other sheet that are Offset(-1,2) from the value that was placed in Range(B2) in the CURRENT sheet. (See Bottom of Post for where this value is placed) Then the user selects a value from the list in Combobox2, Code below : ~~~~~~~~~~~~~~ Combobox2 Code ~~~~~~~~~~~~~~~ Private Sub ComboBox2_DropButtonClick() Application.ScreenUpdating = False If ComboBox2.ListCount 0 Then Exit Sub 'Place the References in here for the Roll Numbers and Lengths Dim lastcell As Long Dim myrow As Long On Error Resume Next lastcell = workSheets("InspectionData").Cells(Rows.Count, "A").End(xlUp).Row With ActiveWorkbook.workSheets("InspectionData") For myrow = 2 To lastcell If .Cells(myrow, 1) < "" Then If .Cells(myrow, 1).Offset(-1, 2).Text = Sheet5.Range("B2").Value And .Cells(myrow, 1).Offset(0, 0).Value = ComboBox1.Text And IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then For i = 2 To 22 If Cells(myrow, 3).Offset(i, 0).Value < "" Then ComboBox2.AddItem Cells(myrow, 3).Offset(i, 0) ComboBox2.List(ComboBox2.ListCount - 1, 1) = Cells(myrow, 3).Offset(i, 0).Address End If Next i End If End If Next End With Application.ScreenUpdating = True End Sub ~~~~~~~~~~~~~~ End of Code ~~~~~~~~~~~~~~~~~~ The Above code lists the values that are Offset between Offset(2,2) - Offset(22,2) from the Value in the other sheet that was Selected in Combobox1. (See Bottom of Post for where this value is placed) The values chosen from the Comboboxes 1 & 2 from the userform are placed int he Current sheet byt he Commanbutton Click event below : ~~~~~~~~~~~ CommandButton Click Code ~~~~~~~~~ Private Sub CommandButton1_Click() With Sheet5 ..Select ActiveCell.Value = UserForm11.ComboBox1.Value ActiveCell.Offset(0, 5).Value = UserForm11.ComboBox2.Value ActiveCell.Offset(0, 1).Value = UserForm11.TextBox1.Value ' <=== This value does not populate Unload Me End With End Sub ~~~~~~~~~~~~ End of Code ~~~~~~~~~~~~~~~~~~~ So far ALL is WELL and Working Great. NOW, what i am trying to do is populate some other DATA from the other sheet into the current sheet that is OFFSET from the Value chosen in Combobox2. I want to ADD the value that is Offset(0,7).value from Combobox2.value Chosen and Place it in ActiveCell.Offset(0, 1).Value. Can anyoine assist me in this ? Corey.... |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Populate order sheet with data from work sheet | Excel Worksheet Functions | |||
how can i re-populate a userform with data already entered? | New Users to Excel | |||
Populate sheet from userform | Excel Programming | |||
Populate Excel Userform with Sheet names | Excel Programming | |||
Populate Userform text boxes in VBA with VLookup data from #2 worksheet | Excel Programming |