Sub test()
Dim i As Long, Message As String
Range("B2:D2")=""
For i = 2 To 4
Message = InputBox("Combien voulez-vous de mot FONT")
If Message = 1 Then
Cells(2, 2) = 1
ElseIf Message = 2 Then
Cells(2, 2) = 1
Cells(2, 3) = 1
ElseIf Message = 3 Then
Cells(2, 2) = 1
Cells(2, 3) = 1
Cells(2, 4) = 1
End If
Exit For
Next i
End Sub
Sub AFH2_()
x = InputBox("entrez le nombre de fois", "entrez un nombre", 0)
If x > 0 Then
Cells(1, 1) = "Ainsi"
For i = 2 To 2 + x
Cells(1, i) = "font"
Next i
Cells(1, 3 + x) = "HEY"
Application.ActiveSheet.Columns.AutoFit
End If
End Sub
Sub AFH2_()
Dim x, arr
x = InputBox("entrez le nombre de fois", "entrez un nombre", 0)
If x > 0 Then
arr = Split("Ainsi" & Application.Rept(" font", x) & " HEY", " ")
Cells(1, 1).Resize(1, UBound(arr) + 1) = arr
Application.ActiveSheet.Columns.AutoFit
End If
End Sub
Option Explicit
Sub test()
Dim i As Long, Message
Range("B2:D2") = ""
For i = 2 To 4
Message = InputBox("Combien voulez-vous de mot FONT")
If Message = 1 Then
Cells(2, 2) = 1
If IsNumeric(Cells(i, 2)) = False Then
Exit Sub
End If
ElseIf Message = 2 Then
Cells(2, 2) = 1
Cells(2, 3) = 1
If IsNumeric(Cells(i, 2)) = False Then
Exit Sub
End If
ElseIf Message = 3 Then
Cells(2, 2) = 1
Cells(2, 3) = 1
Cells(2, 4) = 1
If IsNumeric(Cells(i, 2)) = False Then
Exit Sub
End If
Else
MsgBox "Veuillez mettre un nombre entre 1 et 3"
End If
Exit For
Next i
End Sub
re
ca n'est pas possible il ajoute pas 1 comme ca tu a du faire une erreur
Sub AFH2_()
x = InputBox("entrez le nombre de fois", "entrez un nombre", 0)
If x > 0 Then
Cells(1, 1) = "Ainsi"
For i = 2 To 2 + x - 1
Cells(1, i) = "font"
Next i
Cells(1, 3 + x) = "HEY"
Application.ActiveSheet.Columns.AutoFit
End If
End Sub
autant pour moi c'est x-1
End SubVB:Sub AFH2_() x = InputBox("entrez le nombre de fois", "entrez un nombre", 0) If x > 0 Then Cells(1, 1) = "Ainsi" For i = 2 To 2 + x - 1 Cells(1, i) = "font" Next i Cells(1, 3 + x) = "HEY" Application.ActiveSheet.Columns.AutoFit End If End Sub