VBA List current active projects per person from Table

7thwave

New Member
Joined
Mar 23, 2018
Messages
4
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?

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]
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,721
Messages
6,174,096
Members
452,542
Latest member
Bricklin

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