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

celle modificabili

Ultimo Aggiornamento: 24/08/2022 20:37
Post: 29
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
04/08/2022 22:41

Ciao a tutti.
Questa macro è per modificare solo certe colonne

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'------------------------------------------------------------------------------
'per scrivere modificare solo in certe colonne


   If Not Intersect(Target, Range("C:C, D:D, E:E, F:F, G:G, H:H, K:K")) Is Nothing Then
        ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
       , AllowFormattingCells:=True, AllowFiltering:=True
       
   Else
       
        ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
      , AllowFormattingCells:=False, AllowFiltering:=True
    End If
    
'------------------------------------------------------------------------------

    
   End Sub



è possibile modificare perchè funzioni dalla riga 4 in poi?

Grazie
Post: 29
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
04/08/2022 22:47

Ho provato con

'Dim n As Long
'Dim avviso As String
'If n < 5 Then
'avviso = MsgBox("non puoi modificare questa cella!!!", vbOKOnly + vbCritical, "ATTENZIONE!")
'Exit Sub
'End If


ma non va

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'------------------------------------------------------------------------------
'per scrivere modificare solo in certe colonne

'Dim n As Long
'Dim avviso As String
'If n < 5 Then
'avviso = MsgBox("non puoi modificare questa cella!!!", vbOKOnly + vbCritical, "ATTENZIONE!")
'Exit Sub
'End If

   If Not Intersect(Target, Range("C:C, D:D, E:E, F:F, G:G, H:H, K:K")) Is Nothing Then
        ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
       , AllowFormattingCells:=True, AllowFiltering:=True
       
   Else
       
        ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
      , AllowFormattingCells:=False, AllowFiltering:=True
    End If
    
'------------------------------------------------------------------------------

    
   End Sub
Post: 4.838
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Master
Excel 365
OFFLINE
04/08/2022 23:36

Puoi inserire un If per valutare il numero di riga della cella selezionata (target)

Se questo è inferiore a 4 visualizzi il MsgBox

Alfredo
Post: 30
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
05/08/2022 07:39

Ho messo questo ma non va

'Dim n As Long
'Dim avviso As String
'If n < 5 Then
'avviso = MsgBox("non puoi modificare questa cella!!!", vbOKOnly + vbCritical, "ATTENZIONE!")
'Exit Sub
'End If
Post: 4.839
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Master
Excel 365
OFFLINE
05/08/2022 09:13

Scusa ma n che cosa è?

Alfredo
Post: 31
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
05/08/2022 20:56

Ciao,

n = ActiveCell.Row

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'------------------------------------------------------------------------------
'per scrivere modificare solo in certe colonne

Dim n As Long
Dim avviso As String
n = ActiveCell.Row
If n < 4 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, K:K")) Is Nothing Then
        ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
       , AllowFormattingCells:=True, AllowFiltering:=True
       
   Else
       
        ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
      , AllowFormattingCells:=False, AllowFiltering:=True
    End If
    
'------------------------------------------------------------------------------

    
   End Sub


Post: 4.841
Registrato il: 21/06/2013
Città: NAPOLI
Età: 70
Utente Master
Excel 365
OFFLINE
06/08/2022 13:19

A me questa (che è la tua macro ho solo tolto le istruzioni per la protezione del foglio sostituendole con dei MsgBox funziona

vb
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
'------------------------------------------------------------------------------
'per scrivere modificare solo in certe colonne
 
Dim n As Long
Dim avviso As String
n = ActiveCell.Row
If n < 4 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, K:K")) Is Nothing Then
       ' ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
       , AllowFormattingCells:=True, AllowFiltering:=True
       MsgBox "pippo"
        
   Else
        MsgBox "plutop"
       ' ActiveSheet.Protect Password:="987654", DrawingObjects:=True, Contents:=True, Scenarios:=True _
      , AllowFormattingCells:=False, AllowFiltering:=True
    End If
     
'------------------------------------------------------------------------------
 
     
   End Sub

Alfredo
Post: 36
Registrato il: 18/08/2019
Età: 19
Utente Junior
un saluto
OFFLINE
24/08/2022 20:37

Ciao Alfredo,
la tua modifica funziona
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


Grazie
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]
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 07:01. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com