help populate data in listbox based on combobox

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,430
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hello
i have sheet contains data from a3 : g1000 and userform contains combobox1 and listbox
the proplem when i run userform i can't access to it an show me error run time error70 permission is denied
i hope any body help
VBA Code:
Option Explicit
Dim myData As Range

Private Sub ComboBox1_Change()

  Me.ListBox1.ListIndex = Me.ComboBox1.ListIndex
Dim mySearchRng As Range
Dim myFindRng As Range
Dim myValToFind As String

With Worksheets("sheet3")
myValToFind = ComboBox1.Value
Set mySearchRng = .Columns("g")
End With

Set myFindRng = mySearchRng.Find(What:=myValToFind, _
        LookIn:=xlFormulas, _
        LookAt:=xlWhole, _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, _
        MatchCase:=False)

    ListBox1.AddItem
    With ListBox1
        .List(.ListCount - 1, 0) = myFindRng.Value  'Data from Col A
        .List(.ListCount - 1, 1) = myFindRng.Offset(0, 2).Value 'Data from Col B
        .List(.ListCount - 1, 2) = myFindRng.Offset(0, 3).Value 'Data from Col C
        .List(.ListCount - 1, 3) = myFindRng.Offset(0, 4).Value 'Data from Col D
        .List(.ListCount - 1, 4) = myFindRng.Offset(0, 5).Value 'Data from Col E
        .List(.ListCount - 1, 5) = myFindRng.Offset(0, 6).Value 'Data from Col f
        .List(.ListCount - 1, 6) = myFindRng.Offset(0, 7).Value 'Data from Col g
        
    End With
    
End Sub


Private Sub UserForm_Initialize()
Set myData = Sheet3.Range("g3").CurrentRegion
Me.ComboBox1.List = myData.Offset(7).Value
Me.ListBox1.ColumnCount = 7
Me.ListBox1.List = Me.ComboBox1.List
End Sub
 
now it works but, i have last demand if you don't mind when i add tool two dtpickers one is from date another is to date the data which show in listbox are relating what i choose in DTPICKER for instance as you see in sheet and userform
you noticed i choose date from 10/10/2018 to 10/10/2018 then ignore data of date for john 20/10/2018 i hope this clear
 

Attachments

  • 1.JPG
    1.JPG
    55.8 KB · Views: 4
  • 5.JPG
    5.JPG
    30.6 KB · Views: 4
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Youre welcome!

the proplem when i run userform i can't access to it an show me error run time error70 permission is denied

That is the original request of the thread.

Create a new thread with for each new theme.
 
Upvote 0

Forum statistics

Threads
1,215,558
Messages
6,125,507
Members
449,236
Latest member
Afua

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