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 Autpen()
Set X.qt = ThisWorkbook.Sheets(2).QueryTables(1)
End Sub
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 Autpen()
Set X.qt = ThisWorkbook.Sheets(2).QueryTables(1)
End Sub