È soltanto un Pokémon con le armi o è un qualcosa di più? Vieni a parlarne su Award & Oscar!

Excel Forum Per condividere esperienze su Microsoft Excel

celle modificabili_2

  • Messaggi
  • OFFLINE
    franc.ciccio
    Post: 33
    Registrato il: 18/08/2019
    Età: 19
    Utente Junior
    un saluto
    00 24/08/2022 13:49
    Ciao a tutti.
    Con questa macro posso modificare come formato solo le celle delle colonne
    Range("C:C, D:D, E:E, F:F, G:G, H:H, I:I")
    E' possibile modificarla perchè il collegamento ipertestuale sia possibile solo nella colonna C, ora è per le colonne impostate
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    '------------------------------------------------------------------------------
       
    Dim n As Long
    Dim avviso As String
    n = ActiveCell.Row
    If n < 7 Then
    'avviso = MsgBox("non puoi modificare questa cella!!!", vbOKOnly + vbCritical, "ATTENZIONE!")
    ActiveSheet.Protect Password:="987654"
    Exit Sub
    End If
       
       
       
       If Not Intersect(Target, Range("C:C, D:D, E:E, F:F, G:G, H:H, I:I")) Is Nothing Then
            'ActiveSheet.Unprotect "987654"
            ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
           , AllowFormattingCells:=True, AllowInsertingHyperlinks:=True, AllowFiltering:=True
        Else
            'ActiveSheet.Unprotect "987654"
            ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
            , AllowFormattingCells:=False, AllowInsertingHyperlinks:=False, AllowFiltering:=True
        End If
                    
     
    
    End Sub
    
    


  • OFFLINE
    rollis13
    Post: 1.253
    Registrato il: 16/08/2015
    Città: CORDENONS
    Età: 67
    Utente Veteran
    Excel 2016-32bit Win11
    00 24/08/2022 15:18
    Così, se ho capito la richiesta, fa quello che chiedi:
    Option Explicit
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Dim n      As Long
        Dim avviso As String
        n = ActiveCell.Row
        If n < 7 Then
            'avviso = MsgBox("non puoi modificare questa cella!!!", vbOKOnly + vbCritical, "ATTENZIONE!")
            ActiveSheet.Protect Password:="987654"
            Exit Sub
        End If
        If Not Intersect(Target, Range("C:C, D:D, E:E, F:F, G:G, H:H, I:I")) Is Nothing Then
            'ActiveSheet.Unprotect "987654"
            '---------------------------------------------------------
            Select Case Target.Column
                Case Is = 3
                    ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=True, AllowFiltering:=True
                    MsgBox "Fatto con link"
                Case Else
                    ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=False, AllowFiltering:=True
                    MsgBox "Fatto senza link"
            End Select
            '---------------------------------------------------------
        Else
            'ActiveSheet.Unprotect "987654"
            ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=False, AllowInsertingHyperlinks:=False, AllowFiltering:=True
            MsgBox "Fatto Altro"
        End If
    End Sub

    ______________________________________________________________
    C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto)
  • OFFLINE
    franc.ciccio
    Post: 33
    Registrato il: 18/08/2019
    Età: 19
    Utente Junior
    un saluto
    00 24/08/2022 16:00
    Grazie rollis13
    Qui penso
    Case Is = 3
    corrisponde alla colonna C.
    Se volessi aggiungere altre 2 colonne E/G?
    Case Is = 3 or 5 or 7
    non va.

  • OFFLINE
    franc.ciccio
    Post: 34
    Registrato il: 18/08/2019
    Età: 19
    Utente Junior
    un saluto
    00 24/08/2022 16:04
    Dovrebbe essere così:

    '---------------------------------------------------------
            Select Case Target.Column
                Case Is = 3
                    ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=True, AllowFiltering:=True
                    'MsgBox "Fatto con link"
                                   
                Case Is = 5
                    ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=True, AllowFiltering:=True
                    'MsgBox "Fatto con link"
                  
                Case Is = 7
                    ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=True, AllowFiltering:=True
                    
                Case Else
                    ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=False, AllowFiltering:=True
                    'MsgBox "Fatto senza link"
            End Select
            '---------------------------------------------------------
    
  • OFFLINE
    rollis13
    Post: 1.254
    Registrato il: 16/08/2015
    Città: CORDENONS
    Età: 67
    Utente Veteran
    Excel 2016-32bit Win11
    00 24/08/2022 16:05
    La giusta sintassi è con una virgola non un Or
    [Modificato da rollis13 24/08/2022 16:06]

    ______________________________________________________________
    C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto)
  • OFFLINE
    franc.ciccio
    Post: 35
    Registrato il: 18/08/2019
    Età: 19
    Utente Junior
    un saluto
    00 24/08/2022 16:16
    Grazie rollis13 [SM=g27811] [SM=g27811] [SM=g27811]
  • OFFLINE
    rollis13
    Post: 1.255
    Registrato il: 16/08/2015
    Città: CORDENONS
    Età: 67
    Utente Veteran
    Excel 2016-32bit Win11
    00 24/08/2022 16:22
    Grazie per il riscontro positivo👍, sono contento di essere stato di qualche aiuto.

    ______________________________________________________________
    C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto)
  • OFFLINE
    alfrimpa
    Post: 4.842
    Registrato il: 21/06/2013
    Città: NAPOLI
    Età: 70
    Utente Master
    Excel 365
    00 24/08/2022 20:01
    Rollis13 sei fortunato.

    Io sono ancora in attesa del riscontro a questa

    https://www.freeforumzone.com/d/11807194/celle-modificabili/discussione.aspx

    Alfredo
  • OFFLINE
    rollis13
    Post: 1.256
    Registrato il: 16/08/2015
    Città: CORDENONS
    Età: 67
    Utente Veteran
    Excel 2016-32bit Win11
    00 24/08/2022 21:30
    @alfrimpa, dai che l' OP ora ha ristabilito la parità😁.

    ______________________________________________________________
    C'è chi fa le COSE a CASO e chi fa CASO alle COSE (Ignoto)