AfterRefresh for multiple querytables

tcarter963

New Member
Joined
Aug 3, 2006
Messages
38
I would like to get this to work with multiple querytables on multiple sheets but I'm not sure as to where to start.

Class Module
Public WithEvents qt As QueryTable

Private Sub qt_AfterRefresh(ByVal Success As Boolean)

Dim LastRowColumnT As Long
Dim Selection1 As Range
Dim Selection2 As Range

LastRowColumnT = Range("T301").End(xlUp).Row
Set Selection1 = Range("Y8:AF13")
Set Selection2 = Range("Y8:AF" & LastRowColumnT)
Set Selection3 = Range("U5:W10")
Set Selection4 = Range("U5:W" & LastRowColumnT)

Application.ScreenUpdating = False

On Error GoTo ErrHandler:
ErrHandler:
If Err.Number = 1004 Then
MsgBox "Calculations won't autofill until there are at least 5 time points", vbInformation
Exit Sub
End If

If Success Then Selection3.AutoFill Destination:=Selection4

If Success Then Selection1.AutoFill Destination:=Selection2


Application.ScreenUpdating = True

End Sub

module

Dim X As New Class1

Sub Auto_Open()
Set X.qt = ThisWorkbook.Sheets(2).QueryTables(1)


End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,214,394
Messages
6,119,263
Members
448,881
Latest member
Faxgirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top