Excellists,
I have a table in sheet1 of workbook as shown below. Ik want to add a Command_button that shows a list active projects (Column = Status = WIP) per person (Column = BC = Naam1 or Naam2 or Naam3 etc.). The result could be a msgbox or a listbox; i don't really care. To start i need to define the number of rows in the table (to then code something like: For Each cell In sht.Range("A2:A" & LastRow). My attempt to determine the number of rows fails. What am i doing wrong?
Tyvm for you thoughts,
Luc
[TABLE="width: 655"]
<colgroup><col><col><col span="2"><col><col><col><col span="2"></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]BC[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]6-1-2014[/TD]
[TD] [/TD]
[TD]Klant1[/TD]
[TD] € 150.000[/TD]
[TD]Naam1[/TD]
[TD] [/TD]
[TD]23-02-17[/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]9-3-2016[/TD]
[TD] [/TD]
[TD]Klant2[/TD]
[TD] € 100.000[/TD]
[TD]Naam2[/TD]
[TD] [/TD]
[TD]24-02-17[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]8-1-2016[/TD]
[TD] [/TD]
[TD]Klant3[/TD]
[TD] € 100.000[/TD]
[TD]Naam3[/TD]
[TD] [/TD]
[TD]13-06-16[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]20-7-2017[/TD]
[TD] [/TD]
[TD]Klant4[/TD]
[TD] € 150.000[/TD]
[TD]Naam1[/TD]
[TD] [/TD]
[TD]27-07-17[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]28-9-2015[/TD]
[TD] [/TD]
[TD]Klant5[/TD]
[TD] € 1.000.000[/TD]
[TD]Naam2[/TD]
[TD] [/TD]
[TD]25-04-17[/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]21-12-2016[/TD]
[TD] [/TD]
[TD]Klant6[/TD]
[TD] € 500.000[/TD]
[TD]Naam3[/TD]
[TD] [/TD]
[TD]10-01-17[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]22-12-2016[/TD]
[TD] [/TD]
[TD]Klant7[/TD]
[TD] € 250.000[/TD]
[TD]Naam1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]23-12-2016[/TD]
[TD] [/TD]
[TD]Klant8[/TD]
[TD] € 500.000[/TD]
[TD]Naam2[/TD]
[TD] [/TD]
[TD]7-08-17[/TD]
[TD]LOST[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]24-12-2016[/TD]
[TD] [/TD]
[TD]Klant9[/TD]
[TD] € 250.000[/TD]
[TD]Naam3[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]8-8-2014[/TD]
[TD] [/TD]
[TD]Klant10[/TD]
[TD] € 3.000.000[/TD]
[TD]naam4[/TD]
[TD] [/TD]
[TD]12-07-16[/TD]
[TD]LOST[/TD]
[/TR]
</tbody>[/TABLE]
I have a table in sheet1 of workbook as shown below. Ik want to add a Command_button that shows a list active projects (Column = Status = WIP) per person (Column = BC = Naam1 or Naam2 or Naam3 etc.). The result could be a msgbox or a listbox; i don't really care. To start i need to define the number of rows in the table (to then code something like: For Each cell In sht.Range("A2:A" & LastRow). My attempt to determine the number of rows fails. What am i doing wrong?
Code:
Sub BClist()
Dim myWorkSheet As Worksheet, myTable As ListObject, countRows As Long
Set myWorkSheet = ActiveWorkbook.Worksheets("Sheet1")
Set myTable = myWorkSheet.ListObjects("Table1")
countRows = myTable.DataBodyRange.Rows.Count
Debug.Print countRows
End Sub
Tyvm for you thoughts,
Luc
[TABLE="width: 655"]
<colgroup><col><col><col span="2"><col><col><col><col span="2"></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]BC[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]6-1-2014[/TD]
[TD] [/TD]
[TD]Klant1[/TD]
[TD] € 150.000[/TD]
[TD]Naam1[/TD]
[TD] [/TD]
[TD]23-02-17[/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]9-3-2016[/TD]
[TD] [/TD]
[TD]Klant2[/TD]
[TD] € 100.000[/TD]
[TD]Naam2[/TD]
[TD] [/TD]
[TD]24-02-17[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]8-1-2016[/TD]
[TD] [/TD]
[TD]Klant3[/TD]
[TD] € 100.000[/TD]
[TD]Naam3[/TD]
[TD] [/TD]
[TD]13-06-16[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]20-7-2017[/TD]
[TD] [/TD]
[TD]Klant4[/TD]
[TD] € 150.000[/TD]
[TD]Naam1[/TD]
[TD] [/TD]
[TD]27-07-17[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]28-9-2015[/TD]
[TD] [/TD]
[TD]Klant5[/TD]
[TD] € 1.000.000[/TD]
[TD]Naam2[/TD]
[TD] [/TD]
[TD]25-04-17[/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]21-12-2016[/TD]
[TD] [/TD]
[TD]Klant6[/TD]
[TD] € 500.000[/TD]
[TD]Naam3[/TD]
[TD] [/TD]
[TD]10-01-17[/TD]
[TD]WON[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]22-12-2016[/TD]
[TD] [/TD]
[TD]Klant7[/TD]
[TD] € 250.000[/TD]
[TD]Naam1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]23-12-2016[/TD]
[TD] [/TD]
[TD]Klant8[/TD]
[TD] € 500.000[/TD]
[TD]Naam2[/TD]
[TD] [/TD]
[TD]7-08-17[/TD]
[TD]LOST[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]24-12-2016[/TD]
[TD] [/TD]
[TD]Klant9[/TD]
[TD] € 250.000[/TD]
[TD]Naam3[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]WIP[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]8-8-2014[/TD]
[TD] [/TD]
[TD]Klant10[/TD]
[TD] € 3.000.000[/TD]
[TD]naam4[/TD]
[TD] [/TD]
[TD]12-07-16[/TD]
[TD]LOST[/TD]
[/TR]
</tbody>[/TABLE]