tabstabstrip

Using TabStrip Tabs Captions to lookup data


As my User Form Opens, I create 'x' amount of tabs, based on a list generated elsewhere:

TaskOwners = ws.Range("W" & Rows.Count).End(xlUp).Row - 1 'MsgBox LastRow1

For i = 2 To TaskOwners + 1

    ct1.Tabs.Add , Range("W" & i)

Next i

This works fine.

My intention is that as as I click one of the generated tabs, the following code will update the TaskList.List

Set ws = ThisWorkbook.Worksheets("Clean_Import")
  
ws.Activate
On Error Resume Next
ws.ShowAllData
On Error GoTo 0

    ws.Range("A1:K1000").AutoFilter Field:=3, Criteria1:="[insert selected tab name here]"

    Range("A:A").Select
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("TempSheet").Select
    
    Columns("A:A").Select
   Range("A2").Activate
    ActiveSheet.Paste

TaskList.List = Sheets("TempSheet").Range("A2:A100").Value

This will create a list box from which I can select to fill textboxes etc. that will run off a vlookup.

My issue I am having is identifying the tab name, they don't operate like a textbox or label, so what will my Criteria1 be, how do I reference my tabs names?

Thanks in advance,

Bill


Solution

  • After some trial and error.

    TabStrip1.SelectedItem.Caption