[Visual Basic Excel] problème de macro
aguirre49
Messages postés
17
Date d'inscription
Statut
Membre
Dernière intervention
-
yeliel59 Messages postés 1 Date d'inscription Statut Membre Dernière intervention -
yeliel59 Messages postés 1 Date d'inscription Statut Membre Dernière intervention -
J'utilise une macro sous EXCEL pour un certain type de fichier.
Je voudrai qu'elle se lance toute seule lorsque j'ouvre ce type de fichier.
J'ai donc nommé cette macro Workbook_Open() et je l'ai mis dans ThisWorkbook de VBAProject (PERSO.XLS).
Les fichiers concernés se nomment toujours log.csv et la macro doit fonctionner sur l'unique onglet lui-même intitulé: log
Je n'arrive pas à rédiger le début de la macro pour qu'elle ne se lance seulement : si le nom du premier onglet est log alors lancer le reste de la macro, sinon ne rien faire.
Pour info voici ma macro
Je voudrai qu'elle se lance toute seule lorsque j'ouvre ce type de fichier.
J'ai donc nommé cette macro Workbook_Open() et je l'ai mis dans ThisWorkbook de VBAProject (PERSO.XLS).
Les fichiers concernés se nomment toujours log.csv et la macro doit fonctionner sur l'unique onglet lui-même intitulé: log
Je n'arrive pas à rédiger le début de la macro pour qu'elle ne se lance seulement : si le nom du premier onglet est log alors lancer le reste de la macro, sinon ne rien faire.
Pour info voici ma macro
Columns("A:A").Select Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _ Semicolon:=True, Comma:=False, Space:=False, Other:=False, FieldInfo _ :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _ Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _ ), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array _ (20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), _ Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array( _ 33, 1), Array(34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), _ Array(40, 1)), TrailingMinusNumbers:=True Sheets("log").Select Sheets.Add Sheets("log").Select Range("A1:A2674").Select Selection.Copy Sheets.Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.LargeScroll Down:=-1 Range("A2641").Select ActiveWindow.LargeScroll Down:=-1 Range("A2608").Select ActiveWindow.LargeScroll Down:=-1 Range("A2575").Select ActiveWindow.LargeScroll Down:=-1 Range("A2542").Select ActiveWindow.LargeScroll Down:=-1 Range("A2509").Select ActiveWindow.LargeScroll Down:=-1 Range("A2476").Select ActiveWindow.LargeScroll Down:=-1 Range("A2443").Select ActiveWindow.LargeScroll Down:=-1 Range("A2410").Select ActiveWindow.LargeScroll Down:=-1 Range("A2377").Select ActiveWindow.LargeScroll Down:=-1 Range("A2344").Select ActiveWindow.LargeScroll Down:=-1 Range("A2311").Select ActiveWindow.LargeScroll Down:=-1 Range("A2278").Select ActiveWindow.LargeScroll Down:=-1 Range("A2245").Select ActiveWindow.LargeScroll Down:=-1 Range("A2212").Select ActiveWindow.LargeScroll Down:=-1 Range("A2179").Select ActiveWindow.LargeScroll Down:=-1 Range("A2146").Select ActiveWindow.LargeScroll Down:=-1 Range("A2113").Select ActiveWindow.LargeScroll Down:=-1 Range("A2080").Select ActiveWindow.LargeScroll Down:=-1 Range("A2047").Select ActiveWindow.LargeScroll Down:=-1 Range("A2014").Select ActiveWindow.LargeScroll Down:=-1 Range("A1981").Select ActiveWindow.LargeScroll Down:=-1 Range("A1948").Select ActiveWindow.LargeScroll Down:=-1 Range("A1915").Select ActiveWindow.LargeScroll Down:=-1 Range("A1882").Select ActiveWindow.LargeScroll Down:=-1 Range("A1849").Select ActiveWindow.LargeScroll Down:=-1 Range("A1816").Select ActiveWindow.LargeScroll Down:=-1 Range("A1783").Select ActiveWindow.LargeScroll Down:=-1 Range("A1750").Select ActiveWindow.LargeScroll Down:=-1 Range("A1717").Select ActiveWindow.LargeScroll Down:=-1 Range("A1684").Select ActiveWindow.LargeScroll Down:=-1 Range("A1651").Select ActiveWindow.LargeScroll Down:=-1 Range("A1618").Select ActiveWindow.LargeScroll Down:=-1 Range("A1585").Select ActiveWindow.LargeScroll Down:=-1 Range("A1552").Select ActiveWindow.LargeScroll Down:=-1 Range("A1519").Select ActiveWindow.LargeScroll Down:=-1 Range("A1486").Select ActiveWindow.LargeScroll Down:=-1 Range("A1453").Select ActiveWindow.LargeScroll Down:=-1 Range("A1420").Select ActiveWindow.LargeScroll Down:=-1 Range("A1387").Select ActiveWindow.LargeScroll Down:=-1 Range("A1354").Select ActiveWindow.LargeScroll Down:=-1 Range("A1321").Select ActiveWindow.LargeScroll Down:=-1 Range("A1288").Select ActiveWindow.LargeScroll Down:=-1 Range("A1255").Select ActiveWindow.LargeScroll Down:=-1 Range("A1222").Select ActiveWindow.LargeScroll Down:=-1 Range("A1189").Select ActiveWindow.LargeScroll Down:=-1 Range("A1156").Select ActiveWindow.LargeScroll Down:=-1 Range("A1123").Select ActiveWindow.LargeScroll Down:=-1 Range("A1090").Select ActiveWindow.LargeScroll Down:=-1 Range("A1057").Select ActiveWindow.LargeScroll Down:=-1 Range("A1024").Select ActiveWindow.LargeScroll Down:=-1 Range("A991").Select ActiveWindow.LargeScroll Down:=-1 Range("A958").Select ActiveWindow.LargeScroll Down:=-1 Range("A925").Select ActiveWindow.LargeScroll Down:=-1 Range("A892").Select ActiveWindow.LargeScroll Down:=-1 Range("A859").Select ActiveWindow.LargeScroll Down:=-1 Range("A826").Select ActiveWindow.LargeScroll Down:=-1 Range("A793").Select ActiveWindow.LargeScroll Down:=-1 Range("A760").Select ActiveWindow.LargeScroll Down:=-1 Range("A727").Select ActiveWindow.LargeScroll Down:=-1 Range("A694").Select ActiveWindow.LargeScroll Down:=-1 Range("A661").Select ActiveWindow.LargeScroll Down:=-1 Range("A628").Select ActiveWindow.LargeScroll Down:=-1 Range("A595").Select ActiveWindow.LargeScroll Down:=-1 Range("A562").Select ActiveWindow.LargeScroll Down:=-1 Range("A529").Select ActiveWindow.LargeScroll Down:=-1 Range("A496").Select ActiveWindow.LargeScroll Down:=-1 Range("A463").Select ActiveWindow.LargeScroll Down:=-1 Range("A430").Select ActiveWindow.LargeScroll Down:=-1 Range("A397").Select ActiveWindow.LargeScroll Down:=-1 Range("A364").Select ActiveWindow.LargeScroll Down:=-1 Range("A331").Select ActiveWindow.LargeScroll Down:=-1 Range("A298").Select ActiveWindow.LargeScroll Down:=-1 Range("A265").Select ActiveWindow.LargeScroll Down:=-1 Range("A232").Select ActiveWindow.LargeScroll Down:=-1 Range("A199").Select ActiveWindow.LargeScroll Down:=-1 Range("A166").Select ActiveWindow.LargeScroll Down:=-1 Range("A133").Select ActiveWindow.LargeScroll Down:=-1 Range("A100").Select ActiveWindow.LargeScroll Down:=-1 Range("A67").Select ActiveWindow.LargeScroll Down:=-1 Range("A34").Select ActiveWindow.LargeScroll Down:=-1 Columns("I:I").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("B:B").Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.SmallScroll ToRight:=4 Columns("M:M").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("C:C").Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.SmallScroll ToRight:=4 Columns("Q:Q").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("D:D").Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.SmallScroll ToRight:=3 Columns("U:U").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("E:E").Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.SmallScroll ToRight:=5 Columns("Y:Y").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("F:F").Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.SmallScroll ToRight:=3 Columns("AC:AC").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("G:G").Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.SmallScroll ToRight:=5 Columns("AG:AG").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("H:H").Select ActiveSheet.Paste Sheets("log").Select ActiveWindow.SmallScroll ToRight:=4 Columns("AK:AK").Select Application.CutCopyMode = False Selection.Copy Sheets.Select Columns("I:I").Select ActiveSheet.Paste End Sub
A voir également:
- [Visual Basic Excel] problème de macro
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Visual basic - Télécharger - Langages
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Microsoft 365 basic - Accueil - Microsoft Office