I need to select a range (multiple column) inside a table and to do so, I use the name of the column. The table may change in size so I though this was an easy way to do it.
Dim first_col_index As Integer
first_col_index = table_roses.ListColumns("Total").Index
ws_roses.Range(table_roses & "[[" & table_roses.ListColumns(first_col_index + 1) & "]:[" & table_roses.ListColumns(table_roses.ListColumns.Count) & "]]").Select
Application.Selection.Clear
This way might not be the best or the most elegant but it works.
My problem is that sometimes table_roses.ListColumns(first_col_index + 1)
and/or table_roses.ListColumns(table_roses.ListColumns.Count)
contain the caracter [ and ]. For exemple, right now my last column is equal to "Collins, Sacha [2]".
Normaly I would just add a backtick to solve the issue like so: =SOUS.TOTAL(9;table_roses[Caron, Luc '[2']])
but now it's inside a variable...
I understand my issue but I dont know how to solve it without changing the logic.
I could add a column before selecting the range, clear it and the remove that column, but I wanted to know if there is a more elegant way to do it!
(Keep in mind that I'm still new to VBA)
Thank you in advance :)