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

2 réponses

1 2
Avatar
garnote
Mais il l'avait déjà son Then ;-)

Santé !



"michdenis" a écrit dans le message de news:
| 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









Avatar
Eric Dufour
Exact.
Ma condition était à l'envers, étant donné qu je manque d'expérience.

If Range("D12") = "" Or Range("D16") = "" Then

Un gros merci.

Érico de Montréal

"garnote" a écrit dans le message de
news:%
Mais il l'avait déjà son Then ;-)

Santé !



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

| 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