Condividi tramite

Aprire UserForm

Anonimo
2013-08-26T14:43:27+00:00

Ciao.

Per aprire una UserForm0 uso il seguente codice:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

   If ActiveCell.Column = 13 And ActiveCell.Row = 7 Then

     UserForm0.Show vbModeless

   End If

   If ActiveCell.Column = 17 And ActiveCell.Row = 24 Then

     UserForm0.Show vbModeless

   End If

End Sub

Problema:

  Tutte le volte che apro il foglio si apre anche l'UserForm0

  e non capisco perché.

Vorrei che il UserForm0 si aprisse solo quando è richiesto: Range("M7") e Range("Q24").

Per piacere potete dirmi dove sbaglio.

Grazie.

Ciao.

Nunzio.

Microsoft 365 e Office | Excel | Per la casa | Windows

Domanda bloccata. Questa domanda è stata eseguita dalla community del supporto tecnico Microsoft. È possibile votare se è utile, ma non è possibile aggiungere commenti o risposte o seguire la domanda.

0 commenti Nessun commento

Risposta accettata dall'autore della domanda

Anonimo
2013-08-30T15:04:45+00:00

Ciao Mauro.

Ho deciso di abbandonare tutto e di rifare il tutto, aggiornandolo alle nuove esigenze,

in un  nuovo UserForm (come il precedente), lo trovo molto più funzionale.

Grazie di tutto.

Alla prossima.

Ciao.

Nunzio.

La risposta è stata utile?

0 commenti Nessun commento

23 risposte aggiuntive

Ordina per: Più utili
  1. Anonimo
    2013-08-26T16:36:00+00:00

    Ciao Andrea.

    Questo è il codice che uso:

    Private Sub Worksheet_Activate()

      Dim rng As Range

      ActiveSheet.DisplayPageBreaks = True                                                 ' tratteggio pagina

      Rem   +++    Inizio carica i dati nella ComboBox    +++

      Set rng = Workbooks("AAvvio.xlsm").Sheets("ArchivioCondomini").Range("B4:D60")

      With Me.ComboBox1

        .Clear

        .ColumnCount = 3

        .ColumnWidths = "30;100;100"                                                       ' Larghezza colonne in Listato della ComboBox

        .List = rng.Value

      End With

      Set rng = Workbooks("AAvvio.xlsm").Worksheets("ArchivioFornitori").Range("B4:F400")

      With Me.ComboBox2

        .Clear

        .ColumnCount = 5

        .ColumnWidths = "25;35;105;105;105"                                                ' Larghezza colonne in Listato della ComboBox

        .List = rng.Value

      End With

      Rem   +++    Fine carica i dati nella ComboBox    +++

      Range("B1").Activate

    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

     If ActiveCell.Column = 13 And ActiveCell.Row = 7 Then

       Worksheets("Condominio").Range("B63") = 617                                         ' UserForm0.Left

       If ActiveCell.Row = 7 Then

         Worksheets("Condominio").Range("B62") = 187                                       ' UserForm0.Top

         UserForm0.Show vbModeless

       End If

     End If

     If ActiveCell.Column = 17 And (ActiveCell.Row = 24 Or ActiveCell.Row = 32) Then

       Worksheets("Condominio").Range("B63") = 617                                         ' UserForm0.Left

       If ActiveCell.Row = 24 Then

         Worksheets("Condominio").Range("B62") = 410                                       ' UserForm0.Top

         UserForm0.Show vbModeless

       End If

       If ActiveCell.Row = 32 Then

         Worksheets("Condominio").Range("B62") = 507                                       ' UserForm0.Top

         UserForm0.Show vbModeless

       End If

     End If

    'Dim rng As Range

    '

    '  Set rng = Union(Range("M7"), Range("Q24"))

    '

    '  If Not Intersect(Target, rng) Is Nothing Then UserForm0.Show vbModeless

    '

    '  Set rng = Nothing

    End Sub

    Grazie.

    Ciao.

    Nunzio.

    La risposta è stata utile?

    0 commenti Nessun commento
  2. Anonimo
    2013-08-26T15:47:57+00:00

    Ciao Andrea.

    Funziona come prima.

    quando apro il foglio apre anche il form.

    Grazie.

    ciao.

    Nunzio.

    Ciao,

    che cosa significa quando apro il foglio? Puoi postare il codice per favore?

    Andrea.

    La risposta è stata utile?

    0 commenti Nessun commento
  3. Anonimo
    2013-08-26T15:30:45+00:00

    Ciao Andrea.

    Funziona come prima.

    quando apro il foglio apre anche il form.

    Grazie.

    ciao.

    Nunzio.

    La risposta è stata utile?

    0 commenti Nessun commento
  4. Anonimo
    2013-08-26T15:03:01+00:00

    Ciao.

    Per aprire una UserForm0 uso il seguente codice:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

     

       If ActiveCell.Column = 13 And ActiveCell.Row = 7 Then

         UserForm0.Show vbModeless

       End If

       If ActiveCell.Column = 17 And ActiveCell.Row = 24 Then

         UserForm0.Show vbModeless

       End If

     

    End Sub

    Problema:

      Tutte le volte che apro il foglio si apre anche l'UserForm0

      e non capisco perché.

    Vorrei che il UserForm0 si aprisse solo quando è richiesto: Range("M7") e Range("Q24").

    Per piacere potete dirmi dove sbaglio.

    Grazie.

    Ciao.

    Nunzio.

    Ciao Nunzio,

    piuttosto che controllare ActiveCell devi controllare Target. Prova con il codice allegato.

    Andrea.


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim rng As Range

    Set rng = Union(Range("M7"), Range("Q24"))

    If Not Intersect(Target, rng) Is Nothing Then UserForm0.Show vbModeless

    Set rng = Nothing

    End Sub


    La risposta è stata utile?

    0 commenti Nessun commento