Previous page | 1 | Next page

celle modificabili

Last Update: 8/6/2022 1:19 PM
Author
Print | Email Notification    
Post: 29
Registered in: 8/18/2019
Age: 17
Junior User
un saluto
OFFLINE
8/4/2022 10:41 PM
 
Modify
 
Delete
 
Quote

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
Registered in: 8/18/2019
Age: 17
Junior User
un saluto
OFFLINE
8/4/2022 10:47 PM
 
Modify
 
Delete
 
Quote

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
Registered in: 6/21/2013
Location: NAPOLI
Age: 68
Master User
Excel 2013
OFFLINE
8/4/2022 11:36 PM
 
Modify
 
Delete
 
Quote

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
Registered in: 8/18/2019
Age: 17
Junior User
un saluto
OFFLINE
8/5/2022 7:39 AM
 
Modify
 
Delete
 
Quote

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
Registered in: 6/21/2013
Location: NAPOLI
Age: 68
Master User
Excel 2013
OFFLINE
8/5/2022 9:13 AM
 
Modify
 
Delete
 
Quote

Scusa ma n che cosa è?

Alfredo
Post: 31
Registered in: 8/18/2019
Age: 17
Junior User
un saluto
OFFLINE
8/5/2022 8:56 PM
 
Modify
 
Delete
 
Quote

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
Registered in: 6/21/2013
Location: NAPOLI
Age: 68
Master User
Excel 2013
OFFLINE
8/6/2022 1:19 PM
 
Modify
 
Delete
 
Quote

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
Admin Thread: | Close | Move | Delete | Modify | Email Notification Previous page | 1 | Next page
New Thread
 | 
Reply
Cerca nel forum
Tag discussione
Discussioni Simili   [vedi tutte]
Feed | Forum | Bacheca | Album | Users | Search | Log In | Register | Admin
Tutti gli orari sono GMT+01:00. Adesso sono le 8:48 PM. : Printable | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2022 FFZ srl - www.freeforumzone.com