Listobject Tables - Essential Pointers For Vba Created and Compiled by Bhaskar. Dated 23.03.2021
Listobject Tables - Essential Pointers For Vba Created and Compiled by Bhaskar. Dated 23.03.2021
Code snippet 1:
‘Check table name by clicking on Formulas tab followed by clicking on Define Name
Worksheets(Range("Table3").Worksheet.Name).Activate
Set Table = Worksheets(Range("Table3").Worksheet.Name).ListObjects("Table3")
References :
1. https://exceloffthegrid.com/vba-excel-tables-code/
2. https://www.thespreadsheetguru.com/blog/2014/6/20/the-vba-guide-to-listobject-
excel-tables
3. https://www.dingbatdata.com/2017/11/24/referencing-listobjects-with-vba/ (Little
bit tricky. Certain excerpts may not necessarily hold true due to version changes.)
4. http://dailydoseofexcel.com/archives/2017/07/29/inconsistent-listrow-copy/ - Do
not use the listrow.copy method while copying values from table DataBodyRange
range to another.
Code snippet 2:
Sub Copy_Active_Former()
'1. A row inside the table in "ActivePlayers" sheet has to be shifted to the
"FormerPlayers" sheet
'to the next available row in a similar table.
'2. The Row copied will append to next available row in "FormerPlayers" Sheet. Rank
data of the
'copied row tone deleted, number column assigned incrementally and the table in
"FormerPlayers"
'to be sorted by number column. (All steps are in code except sorting - which did not
seem necessary)
If x = True Then
Call
FormerPlayerSht(Worksheets(destcell.Worksheet.Name).Range(destcell.Address))
'Need to be careful when passing range as argument to function
Call
ActivePlayerSht(Worksheets(CopyRng.Worksheet.Name).Range(CopyRng.Address)
)
MsgBox "Transfer successfully done !!"
Else
MsgBox "Select rows overlapping with table"
End If
End Sub
Code Snippet 3:
'-----------------------------------------------------------------------------------------------------------
‘Check table name by clicking on Formulas tab followed by clicking on Define Name
Worksheets(Range("Table3").Worksheet.Name).Activate
Set Table = Worksheets(Range("Table3").Worksheet.Name).ListObjects("Table3")
Set LastRow1 = cell.Offset(-1, 0)
End Sub