Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

if Then

12 réponses
Avatar
Eric Dufour
J'ai des problèmes avec la liste de code suivant:
ça bloque à la deuxième ligne déjà....

Merci
_______________________________________________

Sub creation()

Sheets("Creer").Select
If (Cells(D, 12) = "" Or Cells(D, 16) = "") Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub

10 réponses

1 2
Avatar
garnote
Bonsoir,

Quand tu écris Cells(D, 12), à quoi t réfères-tu ?
Quelle est la valeur de D ?
Si tu veux te référer aux cellules ligne4 colonne12
et ligne4 colonne16, la bonne syntaxe est celle-ci :

If Cells(4, 12) = "" Or Cells(4, 16) = "" Then

Serge


"Eric Dufour" a écrit dans le message de news:
J'ai des problèmes avec la liste de code suivant:
ça bloque à la deuxième ligne déjà....

Merci
_______________________________________________

Sub creation()

Sheets("Creer").Select
If (Cells(D, 12) = "" Or Cells(D, 16) = "") Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub


Avatar
michdenis
Pour faire référence à une colonne avec Cells()
la syntaxe n'est pas :
If (Cells(D, 12) = "" Or Cells(D, 16) = "") Then

Mais if cells(12,"D") = "" or Cells(16,"D") = "" then



"Eric Dufour" a écrit dans le message de groupe de discussion :

J'ai des problèmes avec la liste de code suivant:
ça bloque à la deuxième ligne déjà....

Merci
_______________________________________________

Sub creation()

Sheets("Creer").Select
If (Cells(D, 12) = "" Or Cells(D, 16) = "") Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub
Avatar
Luc Monnet
Moi je pense qu'il faut ecrire
If (Cells(4, 12) = "" Or Cells(4, 16) = "") Then
Il me semble aussi qu'il faut donner a la commande Cells les informations
Ligne, Colonne

"michdenis" a écrit dans le message de news:

Pour faire référence à une colonne avec Cells()
la syntaxe n'est pas :
If (Cells(D, 12) = "" Or Cells(D, 16) = "") Then

Mais if cells(12,"D") = "" or Cells(16,"D") = "" then



"Eric Dufour" a écrit dans le message de groupe de
discussion :

J'ai des problèmes avec la liste de code suivant:
ça bloque à la deuxième ligne déjà....

Merci
_______________________________________________

Sub creation()

Sheets("Creer").Select
If (Cells(D, 12) = "" Or Cells(D, 16) = "") Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub



Avatar
Youky \(BJ\)
Salut;
Ta macro que je viens de reprendre en simplifiant qlq lignes

Sub creation()
Sheets("Creer").Select
If [D12] = "" Or [D16] = "" Then
MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Exit sub 'on quitte
Else
Application.ScreenUpdating = False
Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
'_________________EFFACE le texte
Range("H22").ClearContents
Rows("22:22").RowHeight = 9.75
'__________________ Copier-collage special valeur du type de financement

[H6]=[H6]
'___________________ Copier-coller specialement le nom d'installation
[D12]=[D12]
[D14]=[D14]
'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Interior.ColorIndex = 34
Range("M48:M49").Interior.ColorIndex = 2
Range("M48:M49").Locked = False
Range("M48:M49").FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie


Range("L51:L52").Interior.ColorIndex = 34
Range("M51:M52").Interior.ColorIndex = 2
Range("M51:M52").Locked = False
Range("M51:M52")..FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = True
End If
End Sub

--
Youky (BJ)



"Eric Dufour" a écrit dans le message de news:

J'ai des problèmes avec la liste de code suivant:
ça bloque à la deuxième ligne déjà....

Merci
_______________________________________________

Sub creation()

Sheets("Creer").Select
If (Cells(D, 12) = "" Or Cells(D, 16) = "") Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub


Avatar
michdenis
| il faut donner a la commande Cells les informations Ligne, Colonne

Et tu peux utiliser la lettre au lieu de la valeur numérique pour la colonne :
Cells(16,4) ou Cells(16,"D") c'est du pareille au même.
Avatar
Eric Dufour
débloqué, mais, comment je fais pour avoir la condition suivante:
Il faut que les deux cellules soit rempli (D12 et D16)?

Merci

Éric De Montréal

(Youki, ta formule ne fonctionne pas)

Sub creation()

Sheets("Creer").Select
'If (Cells(D, 12) _) "" And Cells(D, 16) = "") Then
If Cells(4, 12) <> "0" And Cells(4, 16) <> "0" Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub
Avatar
garnote
Essaie ceci :

If Range("D12")<>"" and Range("D16")<>""

Serge

"Eric Dufour" a écrit dans le message de news:
débloqué, mais, comment je fais pour avoir la condition suivante:
Il faut que les deux cellules soit rempli (D12 et D16)?

Merci

Éric De Montréal

(Youki, ta formule ne fonctionne pas)

Sub creation()

Sheets("Creer").Select
'If (Cells(D, 12) _) "" And Cells(D, 16) = "") Then
If Cells(4, 12) <> "0" And Cells(4, 16) <> "0" Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub


Avatar
Eric Dufour
Non, il y a un message d'erreur de Go To


"garnote" a écrit dans le message de
news:
Essaie ceci :

If Range("D12")<>"" and Range("D16")<>""

Serge

"Eric Dufour" a écrit dans le message de news:

débloqué, mais, comment je fais pour avoir la condition suivante:
Il faut que les deux cellules soit rempli (D12 et D16)?

Merci

Éric De Montréal

(Youki, ta formule ne fonctionne pas)

Sub creation()

Sheets("Creer").Select
'If (Cells(D, 12) _) "" And Cells(D, 16) = "") Then
If Cells(4, 12) <> "0" And Cells(4, 16) <> "0" Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la
protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub






Avatar
garnote
Il doit me manquer des détails ;-(

Sub Test()
If Range("D12") <> "" And Range("D16") <> "" Then MsgBox "Les deux cellules sont remplies."
End Sub

Serge





"Eric Dufour" a écrit dans le message de news: %232$
Non, il y a un message d'erreur de Go To


"garnote" a écrit dans le message de news:
Essaie ceci :

If Range("D12")<>"" and Range("D16")<>""

Serge

"Eric Dufour" a écrit dans le message de news:
débloqué, mais, comment je fais pour avoir la condition suivante:
Il faut que les deux cellules soit rempli (D12 et D16)?

Merci

Éric De Montréal

(Youki, ta formule ne fonctionne pas)

Sub creation()

Sheets("Creer").Select
'If (Cells(D, 12) _) "" And Cells(D, 16) = "") Then
If Cells(4, 12) <> "0" And Cells(4, 16) <> "0" Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub









Avatar
michdenis
| Non, il y a un message d'erreur de Go To

à la fin d'une ligne de code débutant par If il doit y avoir un Then
comme Garnote doit avoir sa petite bière à la fin de la journée !
;-)
If Range("D12")<>"" and Range("D16")<>"" THEN




"Eric Dufour" a écrit dans le message de groupe de discussion :
#2$
Non, il y a un message d'erreur de Go To


"garnote" a écrit dans le message de
news:
Essaie ceci :

If Range("D12")<>"" and Range("D16")<>""

Serge

"Eric Dufour" a écrit dans le message de news:

débloqué, mais, comment je fais pour avoir la condition suivante:
Il faut que les deux cellules soit rempli (D12 et D16)?

Merci

Éric De Montréal

(Youki, ta formule ne fonctionne pas)

Sub creation()

Sheets("Creer").Select
'If (Cells(D, 12) _) "" And Cells(D, 16) = "") Then
If Cells(4, 12) <> "0" And Cells(4, 16) <> "0" Then

MsgBox "Vous devez saisir le nom de votre établissement et le nom de
l'installation"
Else

Application.ScreenUpdating = False

Sheets("Formulaire").Visible = xlSheetVisible
Sheets("Formulaire").Select
Sheets("Formulaire").Copy After:=Sheets(Sheets.Count)
' Sheets(Sheets.Count - 1).Name = "Eric"
ActiveSheet.Unprotect Password:="Regie" '__________désactive la
protection
Range("C10").Select
'_________________EFFACE le texte
Range("H22").Select
Selection.ClearContents
Rows("22:22").RowHeight = 9.75
Range("O22").Select

'__________________ Copier-collage special valeur du type de financement
Range("H6").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("H7").Select

'___________________ Copier-coller specialement le nom d'installation
Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("D14").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:úlse, Transpose:úlse
Application.CutCopyMode = False


'_____________________Macro pour masquer si complémentaire dans P6
'Worksheets(Worksheets.Count).Select
If [P6].Value = 2 Then
Rows("40:41").EntireRow.Hidden = True
'___________________
Range("L48:L49").Select
Selection.Interior.ColorIndex = 34
Range("M48:M49").Select
Selection.Interior.ColorIndex = 2
Range("M48:M49").Select
Selection.Locked = False
Selection.FormulaHidden = False
Else
Rows("40:41").EntireRow.Hidden = False
'_______________________Macro pour Superficie visée et Superficie
Range("L51:L52").Select
Selection.Interior.ColorIndex = 34
Range("M51:M52").Select
Selection.Interior.ColorIndex = 2
Selection.Locked = False
Selection.FormulaHidden = False
'_______________________coloré
Range("M78").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 35
End With
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
End If
'_______________________Macro pour zoomer à la largeur
Range("A2:O10").Select
Range("O10").Activate
ActiveWindow.Zoom = True
Range("A1").Select
ActiveSheet.ScrollArea = "A1:O100"
Sheets("Formulaire").Visible = xlVeryHidden
ActiveSheet.Protect Password:="Regie" '______________ l'active
Range("A1").Select
Application.ScreenUpdating = False

End If
End Sub






1 2