I am relatively new to coding in general, but here goes:
I have a huge list of membershipdata which I am trying to organize. This is going to be done weekly as the data is variable, so I am trying to automate the work a bit.
I have written (with help) a code that copies an entire row of data if a specific cell contains a specific text, and pastes it in another sheet under an existing table.
However, when doing this using a macro, the table doesnt resize accordingly, like it would do when using ctrl+c and ctrl+v. I.e. when there is more data this week then last, the table isnt large enough, and so the sorting options in the table wont sort all the data.
I have been able to resize the table using this code:
Sub sortOK()
Dim sht As Worksheet
Dim LastRow As Long
Dim LastColumn As Long
Dim StartCell As Range
Set sht = Worksheets("OK")
Set StartCell = Range("A1")
Worksheets("OK").UsedRange
LastRow = StartCell.SpecialCells(xlCellTypeLastCell).Row
LastColumn = StartCell.SpecialCells(xlCellTypeLastCell).Column
sht.Range(StartCell, sht.Cells(LastRow, LastColumn)).Select
sht.ListObjects("OK").Resize Range(StartCell, sht.Cells(LastRow, LastColumn))
End Sub
This works fine, however it only works when I am viewing this specific sheet, I cant operate it from another sheet. How can I do so?
I would also like to do the same operation in one go on four other lists, each in its own spreadsheet.
I have been stuck on this problem alost an entire day, and my head is about to explode!
Thank you in advance.