ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
The code below works well & now to take it one step more i wish for Table to be sorted A-Z
I added what i thought would work but i see a message about Invalid or Unqualified referance
Headers in Row 1
Values at present are DP2-DP12 & is Table38
Thanks
VBA Code:
Private Sub AddKeyToTableList_Click()
Dim tbl As ListObject
Dim newRow As ListRow
Dim f As Range
Set tbl = Sheets("INFO").ListObjects("Table38")
If TextBox3.Value = "" Then
MsgBox "ENTER NEW KEY TYPE"
Exit Sub
End If
Set f = tbl.Range.Find(TextBox3.Value, , xlValues, xlWhole, , , False)
If Not f Is Nothing Then
MsgBox "THE KEY ALREADY EXISTS"
Exit Sub
End If
Set newRow = tbl.ListRows.Add
newRow.Range(1) = TextBox3.Value
ComboBox1.RowSource = ""
ComboBox1.Clear
ComboBox1.List = tbl.Range.Value
End Sub
I added what i thought would work but i see a message about Invalid or Unqualified referance
Code:
Private Sub AddKeyToTableList_Click()
Dim tbl As ListObject
Dim newRow As ListRow
Dim f As Range
Set tbl = Sheets("INFO").ListObjects("Table38")
If TextBox3.Value = "" Then
MsgBox "ENTER NEW KEY TYPE"
Exit Sub
End If
Set f = tbl.Range.Find(TextBox3.Value, , xlValues, xlWhole, , , False)
If Not f Is Nothing Then
MsgBox "THE KEY ALREADY EXISTS"
Exit Sub
End If
Set newRow = tbl.ListRows.Add
.Sort.SortFields.Clear
.Sort.SortFields.Add KEY:=.ListColumns(1).Range, SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With .Sort
.Header = xlYes
.Apply
newRow.Range(1) = TextBox3.Value
ComboBox1.RowSource = ""
ComboBox1.Clear
ComboBox1.List = tbl.Range.Value
End Sub
Headers in Row 1
Values at present are DP2-DP12 & is Table38
Thanks