I am new to Excel VBA. I need a modification in my code so that I would be able to proceed further.
I want to select multiple table columns in an excel table. Here is my code:
Dim ws As Worksheet
Dim tbl As ListObject
Set ws = Sheets("Sheet1")
Set tbl = ws.ListObjects(1)
Range("tbl[[Column1]:[Column5]]").Select
When I put the table name, it works. but I want to use variable which I have used in my code to select the table columns.
You can use concatenation to use a variable as a table name.
Here is the code:
Dim ws As Worksheet
Dim tbl As ListObject
Set ws = Sheets("Sheet1")
Set tbl = ws.ListObjects(1)
Range(tbl & "[[Column1]:[Column5]]").Select
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With