2

Hoping someone could shed something on my line of vba script below and point out the error:

Sub findKeyword()

Dim tbl as ListObject

set tbl = activesheet.ListOBjects("myTable") 'containing a header row

set r as range

set r = tbl.ListRows(1).Range.Find("name")

End sub

the Find keeps returning nothing when the header called name does exist in the header row of the structured table. On the other hand, set r = activesheet.rows(1).find("name") is able to find the search text.

2
  • 2
    Set r = tbl.HeaderRowRange.Find("name") Commented Dec 7, 2023 at 17:50
  • 1
    Debug.Print tbl.ListRows(1).Range.Address will clarify it all. Commented Dec 7, 2023 at 19:12

1 Answer 1

2

ListRows = all the rows of data in the ListObject.

It's not the range with the headers.

tbl.Listcolumns("name")

will give you a reference to the "name" column.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.