0

I've been wanting to show a filtered data on a listbox from the word that I search for from a table. Currently I have the following code:

'First, setting a as the word I want to search through the first column of the table'

Set a = Sheets("Main").Range("P14")

'setting Enertec Fee'

If a = "ENERTEC" Then

frmFeee.lstAHK.RowSource = "AHK_Fee!A6:D9"
frmFeee.lstMD.RowSource = "AHK_MD!A6:D9"
  
End If

This works but I realised that if I want to add new data on the table, it'll not be updated on the listbox unless I change the code everytime. Is there a better way of going about this? Any help would be greatly appreciated !

I've attached some pictures to help. listbox displaying results

Thank you.

3
  • Does the range "AHK_Fee!A6:D9" contain the filtered data? or do you want to filter it? Commented Jun 11, 2021 at 6:26
  • No it's not filtered, they are just cluster of cells that correspond to Enertec,. What I try to do is that if I were to add a new data under the column heading ENERTEC, the range will have to change to something like "AHK_Fee!A6:D9, A13:D13" and I'm trying to avoid writing a new line of code every time. Commented Jun 11, 2021 at 6:32
  • A bit more searching and you should find your answer. A web search for "vba find last used row" if your data is not in a table. Otherwise, if your data is in a table then you should find the solution here: stackoverflow.com/questions/18030637/… Commented Jun 11, 2021 at 7:56

0

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.