Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

celle modificabili_2

Ultimo Aggiornamento: 24/08/2022 21:30
Post: 33
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
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



Post: 1.253
Registrato il: 16/08/2015
Città: CORDENONS
Età: 67
Utente Veteran
Excel 2016-32bit Win11
OFFLINE
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)
Post: 33
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
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.

Post: 34
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
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
        '---------------------------------------------------------
Post: 1.254
Registrato il: 16/08/2015
Città: CORDENONS
Età: 67
Utente Veteran
Excel 2016-32bit Win11
OFFLINE
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)
Post: 35
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
24/08/2022 16:16

Grazie rollis13 [SM=g27811] [SM=g27811] [SM=g27811]
Post: 1.255
Registrato il: 16/08/2015
Città: CORDENONS
Età: 67
Utente Veteran
Excel 2016-32bit Win11
OFFLINE
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)
Post: 4.842
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Master
Excel 365
OFFLINE
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
Post: 1.256
Registrato il: 16/08/2015
Città: CORDENONS
Età: 67
Utente Veteran
Excel 2016-32bit Win11
OFFLINE
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)
Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Cerca nel forum
Tag discussione
Discussioni Simili   [vedi tutte]
conta celle colorate in automatico (15 messaggi, agg.: 30/05/2019 13:38)
Celle colorate (30 messaggi, agg.: 09/11/2020 10:59)
Contare le celle colorate (43 messaggi, agg.: 04/12/2020 11:04)
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 08:55. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com