Re : Tester une cellule
Bonjour à tous
Une autre façon de faire:
(Copier tout le code VBA ci-dessous dans un module standard, sans oublier les macros: Macro1,..,Macro5)
Pour tester, lancer la macro tests
Code VB:
Dim y As String
Sub tests()
Range("A1") = "toto.dgw": a
Range("A1") = "toto.xls": a
Range("A1") = "toto.pdf": a
Range("A1") = "toto.ppt": a
End Sub
Private Sub a()
Dim strEXT$
strEXT = "XLSDOCDGWPDFPPT"
y = UCase(Mid(Range("A1").Text, InStrRev(Range("A1").Text, ".") + 1, 3))
Application.Run "Macro" & Int(1 + InStr(1, strEXT, y) / 3)
End Sub
[TABLE="width: 550"]
[TR]
[TD]Sub Macro1()
MsgBox "MACRO1", vbInformation, "Extension: " & y
End Sub
[/TD]
[TD]Sub Macro4()
MsgBox "MACRO4", vbInformation, "Extension: " & y
End Sub
[/TD]
[/TR]
[TR]
[TD]Sub Macro2()
MsgBox "MACRO2", vbInformation, "Extension: " & y
End Sub
[/TD]
[TD]Sub Macro5()
MsgBox "MACRO5", vbInformation, "Extension: " & y
End Sub
[/TD]
[/TR]
[TR]
[TD]Sub Macro3()
MsgBox "MACRO3", vbInformation, "Extension: " & y
End Sub
[/TD]
[TD][/TD]
[/TR]
[/TABLE]