listview in a VBA Userform object required error 424

benjamin132

New Member
Joined
Jun 8, 2022
Messages
21
Platform
  1. Windows
Hi everyone,
I have a problem with listview.
I want a table with some informations in my sheets when i click in a button "CommandButton1" but i have an error 424 object required here :
1654674822372.png

Someone know what is my problem ?
Thanks by advance
here is my code :
VBA Code:
Private Sub CommandButton1_Click()
    If Len(Num_SI) = 0 Then
        MsgBox "Vous devez remplir le champ commune avec la liste déroulante"
    ElseIf Len(ComboBox1) = 0 Then
        MsgBox "Vous devez remplir le champ NUM_PE avec la liste déroulante"
    Else
        Sheets("David").Range("I4") = ComboBox1
        Sheets("David").Range("I5") = ComboBox2
        If Sheets("David").Range("I6") = 1 Then
            MsgBox ("Ce site n'existe pas")
        Else
            If (IsError(Sheets("David").Range("I10"))) Then
                    With ListView1
                            With .ColumnHeaders
                            .Clear
                            .Add , , "Nom", 80
                            .Add , , "Ville", 50
                            .Add , , "Age", 50
                        End With
                        With .ListItems
                           .Add , , "Riri"
                        End With
                    .ListSubItems(1).Add , , Sheets("David").Range("I7")
                    .ListSubItems(1).Add , , Sheets("David").Range("I8")
                    .ListSubItems(1).Add , , Round(Sheets("David").Range("I9") * 100, 2)
                    End With
            Else
                MsgBox ("Le site indiqué a " & Sheets("David").Range("I7") & " Emplacements disponibles, " & Sheets("David").Range("I8") & " Nb de baies Max avec " & Round(Sheets("David").Range("I9") * 100, 2) & "% d'occupation 3YP et un taux d'occupation REPO de " & Round(Sheets("David").Range("I10") * 100, 2) & "%")
                Unload Me
            End If
        End If
    End If
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
That error indicates that there isn't a control called ListView1.
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,147
Members
452,615
Latest member
bogeys2birdies

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