Domanda

Alright, I have a workbook wherein each sheet contains a table. These tables are linked to an Access database, which is in turn linked to a SQL database.

The issue I am having is that some, not all, of the tables within my workbooks seems to have data "overflowing" out of the table area. Normally when new records are added to the table (by refreshing the links which connect the Workbook to the Access DB), the table automatically expands to include them. In these instances it is not.

I believe this issue has something to do with filters that were once applied to the tables (not sure what filters as I did not apply them), but I have removed all the filters, and then refreshed the tables, and I still see data extending outside the lower limits of my tables.

My question is how do I fix this, preferably without deleting and re-linking every single table, and also, why has this happened exactly, so that I may prevent it in the future?

Here is a picture:

enter image description here

È stato utile?

Soluzione

Using this code you can update the table also if you have some blank lines...

Dim RowEnd As Double
Dim posi As String

Application.ScreenUpdating = False
posi = ActiveCell.Address
Range("B3").Select
While Selection.Row < 50000
    Selection.End(xlDown).Select
    If (Selection.Row < 50000) Then RowEnd = Selection.Row
Wend
ActiveSheet.ListObjects("Table1").Resize Range("$B$3:$C$" & RowEnd)
Range(posi).Select
Application.ScreenUpdating = True

I suppose you don't have more than 50000 lines... Eventually increase the value.
You can put inside a Button to Update the table, or adding the code in:

Private Sub Worksheet_Change(ByVal Target As Range)

In this case every time you change something inside the sheet the code check... If you work a lot on the sheet you can add a filter of range or adding a button for updating the data at the end of editing...

Altri suggerimenti

I suppose you have:

Application.AutoCorrect.AutoExpandListRange = True

If don't work you can try to force using:

ActiveSheet.ListObjects("Table1").Resize Range("$B$5:$E$36")

giving the new range at the table...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top