I have a query that runs when a page is opened. That query was refreshed to the same sheet. If the query is moved to a new sheet (panel) I am not sure how to modify the code below to reflect this change. Thank you .


 ' Select Patient
 Application.ScreenUpdating = False
    With ActiveSheet
        lastrow = Cells(.Rows.Count, "CA").End(xlUp).Row
    With Selection.Validation
        End With
        With .Range("A2").Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                 xlBetween, Formula1:="=$CA$5:$CA$" & lastrow
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = ""
            .ShowInput = True
            .ShowError = True
        End With
    End With
    Application.ScreenUpdating = True