raffaele1953, 15/05/2018 21.37:A spiegarsi meglio, si ottengono vantaggi sia io che Tu Questa fà un piccolo controllo (sulle colonne J ed M, se non sono scritte non fà nulla) Nel VBA ci sono alcune spiegazioni, se il controllo colonna M non lo vuoi, a destra c'è la riga solo per J. Prova se va bene vbSub Inserisci_Righe() Dim rig As Long rig = ActiveCell.Row 'controllo se sono scritte If Cells(rig, 10) <> "" And Cells(rig, 13) <> "" Then ' oppure If Cells(rig, 10) <> "" Then'non controlla M Range(Cells(rig + 1, 1), Cells(rig + 1, 26)).Insert Shift:=xlDown Range(Cells(rig, 1), Cells(rig, 2)).Copy 'solo la data, oppure anche i turni Range(Cells(rig, 1), Cells(rig, 8)).Copy Cells(rig + 1, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 'ora le colonne N/T Range(Cells(rig, 14), Cells(rig, 20)).Copy Cells(rig + 1, 14).PasteSpecial 'comprese le formule Else MsgBox "non posso aggiungere" End If End Sub
Sub Inserisci_Righe() Dim rig As Long rig = ActiveCell.Row 'controllo se sono scritte If Cells(rig, 10) <> "" And Cells(rig, 13) <> "" Then ' oppure If Cells(rig, 10) <> "" Then'non controlla M Range(Cells(rig + 1, 1), Cells(rig + 1, 26)).Insert Shift:=xlDown Range(Cells(rig, 1), Cells(rig, 2)).Copy 'solo la data, oppure anche i turni Range(Cells(rig, 1), Cells(rig, 8)).Copy Cells(rig + 1, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 'ora le colonne N/T Range(Cells(rig, 14), Cells(rig, 20)).Copy Cells(rig + 1, 14).PasteSpecial 'comprese le formule Else MsgBox "non posso aggiungere" End If End Sub
Sub Inserisci_Righe() Dim rig As Long rig = ActiveCell.Row 'controllo se sono scritte 'If Cells(rig, 10) <> "" And Cells(rig, 13) <> "" Then ' oppure If Cells(rig, 10) <> "" Then 'non controlla M Range(Cells(rig + 1, 1), Cells(rig + 1, 26)).Insert Shift:=xlDown 'Range(Cells(rig, 1), Cells(rig, 2)).Copy 'solo la data 'oppure anche i turni Range(Cells(rig, 1), Cells(rig, 10)).Copy Cells(rig + 1, 1).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 'ora le colonne N/T Range(Cells(rig, 14), Cells(rig, 20)).Copy Cells(rig + 1, 14).PasteSpecial 'comprese le formule Else MsgBox "non posso aggiungere" End If End Sub