Na minha pasta de trabalho, tenho três planilhas possíveis que podem iniciar meu código (Site1, Site2, Site3). Todas elas contêm o seguinte código para iniciar o processo.
Option Explicit
' Script intended to run upon any change in worksheet.
Private Sub worksheet_change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
Main.Switchboard Target
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Todas as minhas regras de validação e formatação de dados são definidas em uma 4ª planilha (VBARefSht) para que um usuário possa atualizar determinados critérios sem tocar no código (por exemplo, intervalo de datas, local, produto, tipos de pedido, etc.).
Este é um exemplo de uma das verificações:
Sub FacilityCheck(ActiveRow As Integer, ActiveCol As Integer, _
WorkingSheet As String)
' If the PO is being entered on the Site2 sheet,
' the plant/facility will be set to Site2.
' Site3 is technically still Site1, but is just
' a different storage area requiring a different sheet.
Dim Fac1 As String
Dim Fac2 As String
Dim FacOut As String
Sheets(VBARefSht).Activate
Fac1 = Cells(Fac1Row, FacCol).Value
Fac2 = Cells(Fac2Row, FacCol).Value
If StrComp(WorkingSheet, Fac2, vbTextCompare) = 0 Then
FacOut = Fac2
Else
FacOut = Fac1
End If
Sheets(WorkingSheet).Activate
Cells(ActiveRow, ActiveCol).Value = FacOut
' FacOut is changed to the process order type for _
' the purpose of determining which formatting rules to apply.
FacOut = Cells(ActiveRow, TypeColIndex).Value
Rules_AllFormatting.RulesSelection ActiveRow, ActiveCol, _
WorkingSheet, FacOut
End Sub
Quando o código é executado, ele alterna entre o ActiveSheet e o VBARefSht.
Existe uma maneira de fazer com que somente o ActiveSheet seja exibido?