Modify cell values based on listBoxes

xPukwe

New Member
Joined
Feb 25, 2020
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone,

So i want to initialise the values of some cells based on a selection from a listbox containing the projects and a listbox containing the weeks

I want the user to select a project that he is working on and then the week number (S1,S2,S3,S4) in which he wants to enter his productivity (or the time he has put in effort to work on that specific project),

With those two selections from listboxes i want to update the values of the cells presents in the worksheet,

Here is the code i have written so far but i have a "Run time error '424' : object required"

VBA Code:
Private Sub UserForm_Initialize()
   
    Dim Col As New Collection
    Dim r As Long
    Dim i As Long
    Dim WeeksArray As Variant
   
    WeeksArray = Array("S1", "S2", "S3", "S4")
   
    r = Sheet1.Range("B" & Rows.Count).End(xlUp).Row
   
    For i = 7 To r
        Col.Add Item:=Sheet1.Range("B" & i).Value
    Next i
   
    For i = 1 To Col.Count
        Me.Deliverables.AddItem Col(i)
    Next i
   
    Me.Weeks.List = WeeksArray
      
End Sub

Private Sub CmdCheck_Click()

    Dim i As Long
    Dim j As Long
    Dim r As Long

    r = Deliverables.ListCount

    For i = 0 To r
        For j = 0 To 3
            If UserForm1.Deliverables.ListIndex = i And UserForm1.Weeks.ListIndex = 0 Then
                Sheet1.Range("G" & i).Value = TxtProd.Value
            ElseIf UserForm1.Deliverables.ListIndex = i And UserForm1.Weeks.ListIndex = 1 Then
                Sheet1.Range("H" & i).Value = TxtProd.Value
            ElseIf UserForm1.Deliverables.ListIndex = i And UserForm1.Weeks.ListIndex = 2 Then
                Sheet1.Range("I" & i).Value = TxtProd.Value
            ElseIf UserForm1.Deliverables.ListIndex = i And UserForm1.Weeks.ListIndex = 3 Then
                Sheet1.Range("J" & i).Value = TxtProd.Value
            End If
        Next j
    Next i

End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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