Automatically Populate Worksheet Depending on Team Name

Q

Qaspec

On my first worksheet "Ws1" I have a table of data. Column A has Team Name
and Column B has Item Num. On worksheet 2 I have a blank worksheet "Ws2" that
I would like to automatically populate with data from "Ws1" when a team is
selected from a list box "LB1" and a button is clicked "VR1". I only want to
select from 'Ws1" and display in "Ws2" those rows where the team name is
equal to the team name selected in the listbox. "Ws2" has the same column
headers. Thanks.
 
J

Joel

Sub getteams()

teamname = Sheets("WS2").LB1.Value
WS2RowCount = 2
With Sheets("Ws1")
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
For WS1RowCount = 2 To LastRow
If .Range("A" & WS1RowCount) = teamname Then
.Rows(WS1RowCount).Copy _
Destination:=Sheets("WS2").Rows(WS2RowCount)
WS2RowCount = WS2RowCount + 1
End If
Next WS1RowCount

End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top