1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| Dim nomFichiertraite As Variant
Dim nomFichierSortie As Variant
'Dim wkbDonnées As Workbook
Dim wkbNew As Workbook
'Dim wshDonnées As Worksheet
'Dim wshSortie As Worksheet
'Dim NbrLigneFichierX As Integer
Dim i As Long
Dim TmpCell As Range
Dim rngColonneGenotype As Range
ChDir (ThisWorkbook.Path)
nomFichiertraite = Application.GetOpenFilename("Classeur Microsoft Excel (*.xls),*.xls", 1, "Sélectionner le fichier à contenant les données")
If nomFichiertraite = False Then Exit Sub
Workbooks.Open nomFichiertraite
Set wkbNew = Workbooks(Workbooks.Count)
nomFichierSortie = Application.GetSaveAsFilename("", "Classeur MiscrosoftExcel (*.xls), *.xls", 1, _
"FICHIER DE SORTIE POUR DATABASE:taper le nom du fichier de sortie")
If nomFichierSortie = False Then Exit Sub
wkbNew.SaveAs (nomFichierSortie)
wkbNew.Activate 'meme pas sur que ce soit utile
' convercolonne Macro
' Macro pour separer la colonne trial et lieu attention celle ci
' -----------------"C ICI que ca merdouill"----------------------
' /////// Le code de Singular ///////
' En assumant que l'entête de colonne se trouve dans la première ligne de la feuille...
Set rngColonneGenotype = ActiveSheet.Rows(1).Find(What:="genotype")
If Not rngColonneGenotype Is Nothing Then
Set rngColonneGenotype = rngColonneGenotype.EntireColumn
' à partir d'ici, rngColonneGenotype représente toute la colonne...
End If
rngColonneGenotype.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
rngColonneGenotype.Cells(1, 1).Offset(0, -1).FormulaR1C1 = "LIEU"
Columns("N:N").TextToColumns Destination:=Range("N1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 2), Array(2, 1)), TrailingMinusNumbers:=True
'Inutil remplacer par la ligne rngColonneGenotype.Cells(1, 1).Offset(0, -1).FormulaR1C1 = "LIEU"
'Range("O1").Select
'ActiveCell.FormulaR1C1 = "LIEU"
' Macro qui supprime les 0, les 9 et les LZM en début de génotype
' Attention la colonne des génotypes doit etre en colonne I
'For i = 1 To Range("I65536").End(xlUp).Row
'If Left(Range("I" & i), 1) = "0" Or Left(Range("I" & i), 1) = "9" Then Range("I" & i) = Right(Range("I" & i), Len(Range("I" & i)) - 1)
'Next i
'For i = 1 To Range("I65536").End(xlUp).Row
'If Left(Range("I" & i), 3) = ("LZM") Then Range("I" & i) = Right(Range("I" & i), Len(Range("I" & i)) - 3)
'Next i
'Alors prefert plutot cette forme moins lourde
For Each TmpCell In Range(Range("I1"), Range("I1").End(xlDown))
If Left(TmpCell, 1) = "0" Or Left(TmpCell, 1) = "9" Then TmpCell = Right(TmpCell, Len(TmpCell) - 1)
If Left(TmpCell, 3) = ("LZM") Then TmpCell = Right(TmpCell, Len(TmpCell) - 3)
Next TmpCell
'wkbDonnées.Close (False) 'tu ne l'as ouvert null part, inutil de le fermer = erreur
'Application.Cursor = xlDefault 'jamais changer pourquoi remettre la valeur par defaut
'Application.ScreenUpdating = True 'jamais mis a False, pourquoi le mettre a true |
Partager