The TableUpdate
event occurs after a query table connected to a data model is updated. Excel uses the Worksheet_TableUpdate
event procedure to trap the TableUpdate
event. The Worksheet_TableUpdate
procedure accepts Target
(the TableObject
) as the parameter which represents the table that was updated.
Creating a data model
You can make a data model by retrieving the data from a file, web, table, database or from any other source listed in the Data > Get Data
as shown in the following image:
In our example, we’ll retrieve the data from a file. Create a text file and insert some data into it. For example, I have entered the following data into a blank text file and saved it as data.txt
using notepad:
a,b,c 1,5,18 10,12,16 12,15,1 1,2,10
Back to Excel, Click Data
tab and select From Text/CSV
from the Get & Transform Data
section to import the data from the data.txt
file:
Select data.txt
file:
The next window shows the preview of data in a table form. Click Load To...
button from the window as shown below image:
Select the Add this data to the Data Model
and click ok:
Data will show on a new Worksheet and a query (data
) will also made which visible on the left side of the sheet under the Queries & Connection
:
If the data in the data.txt
file changes, the changes will not be automatically updated on the table. To update the changes click Data
tab and click Refresh All menu
from the Queries & Connections
section:
The TableUpdate
event occurs after a query table connected to a data model is updated. The Worksheet_TableUpdate
procedures must be in the code module for that worksheet. You can quickly access that code window by right-clicking the worksheet’s tab and selecting the View Code
:
In our data-model, the data imported to new sheet, Sheet2
. Right-click on the Sheet2
tab, select View Code
and write the following code.
Private Sub Worksheet_TableUpdate(ByVal Target As TableObject) MsgBox "Data from the data.txt has been updated" End Sub
Back to Sheet2
and click Data
tab and click Refresh All menu
from the Queries & Connections
section, it will reload (update) the data from the data.txt
file and Excel fires the TableUpdate
event which executes the Worksheet_TableUpdate
event procedure:
by updated May 07, 2020
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.
Permalink
Cannot retrieve contributors at this time
title | keywords | f1_keywords | ms.prod | ms.assetid | ms.date |
---|---|---|---|---|---|
Worksheet.TableUpdate Event (Excel) |
vbaxl10.chm502088 |
vbaxl10.chm502088 |
excel |
69610de6-6884-d5f5-449d-ec1d766d530d |
06/08/2017 |
Worksheet.TableUpdate Event (Excel)
Occurs after a Query table connected to the Data Model is updated on a worksheet.
Syntax
expression . TableUpdate(Target)
expression A variable that represents a Worksheet object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Target | Required | TABLEOBJECT | The Query table with data from the Data Model. |
See also
Concepts
Worksheet Object
- Remove From My Forums
-
Question
-
Trying to use the Worksheet.TableUpdate event in VBA with the following syntax…
«Private Sub Worksheet_TableUpdate(ByVal Target As TableObject)»
but the sub is not triggered when I refresh the only PowerQuery query in the document. The code is on the Sheet1 module as there’s only 1 sheet in the workbook.
What’s the correct syntax for this event? And could you provide a working example (i.e. one that you’ve tested)?
-
Moved by
Wednesday, September 21, 2016 6:35 AM
Move Case
-
Moved by
Answers
-
-
Proposed as answer by
Chenchen Li
Sunday, September 25, 2016 1:11 PM -
Marked as answer by
Chenchen Li
Friday, September 30, 2016 5:19 AM
-
Proposed as answer by
Это не то событие
Примерно так
‘ by ZVI https://www.planetaexcel.ru/forum/index.php?PAGE_NAME=profile_view&UID=127
Dim WithEvents q As QueryTable
Private Sub q_AfterRefresh(ByVal Success As Boolean)
Debug.Print «AfterRefresh», Now
End Sub
Private Sub q_BeforeRefresh(Cancel As Boolean)
Debug.Print «BeforeRefresh», Now
End Sub
Private Sub Workbook_Open()
Application.OnTime Now, Me.Name & «.Start»
End Sub
Sub Start()
Set q = Sheet2.QueryTables(1)
End Sub
Это не то событие
Примерно так
‘ by ZVI https://www.planetaexcel.ru/forum/index.php?PAGE_NAME=profile_view&UID=127
Dim WithEvents q As QueryTable
Private Sub q_AfterRefresh(ByVal Success As Boolean)
Debug.Print «AfterRefresh», Now
End Sub
Private Sub q_BeforeRefresh(Cancel As Boolean)
Debug.Print «BeforeRefresh», Now
End Sub
Private Sub Workbook_Open()
Application.OnTime Now, Me.Name & «.Start»
End Sub
Sub Start()
Set q = Sheet2.QueryTables(1)
End Sub
Замечательный Временно просто медведь , процентов на 20.
Сообщение Это не то событие
Примерно так
‘ by ZVI https://www.planetaexcel.ru/forum/index.php?PAGE_NAME=profile_view&UID=127
Dim WithEvents q As QueryTable
Private Sub q_AfterRefresh(ByVal Success As Boolean)
Debug.Print «AfterRefresh», Now
End Sub
Private Sub q_BeforeRefresh(Cancel As Boolean)
Debug.Print «BeforeRefresh», Now
End Sub
Private Sub Workbook_Open()
Application.OnTime Now, Me.Name & «.Start»
End Sub
Sub Start()
Set q = Sheet2.QueryTables(1)
End Sub
Источник
Vba excel событие tableupdate
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
Trying to use the Worksheet.TableUpdate event in VBA with the following syntax.
«Private Sub Worksheet_TableUpdate(ByVal Target As TableObject)»
but the sub is not triggered when I refresh the only PowerQuery query in the document. The code is on the Sheet1 module as there’s only 1 sheet in the workbook.
What’s the correct syntax for this event? And could you provide a working example (i.e. one that you’ve tested)?
- Moved by Emi Zhang Microsoft contingent staff Wednesday, September 21, 2016 6:35 AM Move Case
Answers
The event occurs after a Query table connected to the Data Model is updated on a worksheet.
Following Create a Data Model in Excel , I am adding data from Access and importing a Table.
Make sure «Add this data to the Data Model» checked.
The event fires after Importing and Refreshing.
All replies
This is the forum to discuss questions and feedback for Microsoft Excel, I’ll move your question to the MSDN forum for Excel
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
Regards,
Emi Zhang
TechNet Community Support
Источник
Vba excel событие tableupdate
Question
Trying to use the Worksheet.TableUpdate event in VBA with the following syntax.
«Private Sub Worksheet_TableUpdate(ByVal Target As TableObject)»
but the sub is not triggered when I refresh the only PowerQuery query in the document. The code is on the Sheet1 module as there’s only 1 sheet in the workbook.
What’s the correct syntax for this event? And could you provide a working example (i.e. one that you’ve tested)?
- Moved by Emi Zhang Microsoft contingent staff Wednesday, September 21, 2016 6:35 AM Move Case
Answers
The event occurs after a Query table connected to the Data Model is updated on a worksheet.
Following Create a Data Model in Excel , I am adding data from Access and importing a Table.
Make sure «Add this data to the Data Model» checked.
The event fires after Importing and Refreshing.
All replies
This is the forum to discuss questions and feedback for Microsoft Excel, I’ll move your question to the MSDN forum for Excel
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
Regards,
Emi Zhang
TechNet Community Support
Источник
Vba excel событие tableupdate
Question
Trying to use the Worksheet.TableUpdate event in VBA with the following syntax.
«Private Sub Worksheet_TableUpdate(ByVal Target As TableObject)»
but the sub is not triggered when I refresh the only PowerQuery query in the document. The code is on the Sheet1 module as there’s only 1 sheet in the workbook.
What’s the correct syntax for this event? And could you provide a working example (i.e. one that you’ve tested)?
- Moved by Emi Zhang Microsoft contingent staff Wednesday, September 21, 2016 6:35 AM Move Case
Answers
The event occurs after a Query table connected to the Data Model is updated on a worksheet.
Following Create a Data Model in Excel , I am adding data from Access and importing a Table.
Make sure «Add this data to the Data Model» checked.
The event fires after Importing and Refreshing.
All replies
This is the forum to discuss questions and feedback for Microsoft Excel, I’ll move your question to the MSDN forum for Excel
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
Regards,
Emi Zhang
TechNet Community Support
Источник
Adblock
detector
Как обработать событие Worksheet_TableUpdate |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |