Spliter une colonne

teodormircea

XLDnaute Occasionnel
Bonjour le forum,

J'ai trouve cette macros qui splitte les valeurs dans une colonne et copie les lignes afférentes dans des feuillets nomes d'après les valeurs de la colonne splitte.
Le truc c'est que ça marche seulement sur la première colonne, j'ai besoin d'un coup de main pour le faire marcher sur les autres colonnes en dehors de la 1ere
 

Pièces jointes

  • Spliter Liste Clients.xls
    42.5 KB · Affichages: 63

PMO2

XLDnaute Accro
Re : Spliter une colonne

Bonjour,

Essayez avec le code modifié suivant

Code:
Public Sub ProcessData()
    Dim i As Long
    Dim LastRow As Long
    Dim NextRow As Long
    Dim this As Worksheet
    Dim sh As Worksheet
    Dim ii As Integer
    ii = CLng(InputBox(Prompt:="Quelle colonne ?"))
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    Set this = ActiveSheet
    With this
        LastRow = .Cells(.Rows.Count, ii).End(xlUp).Row
        For i = 2 To LastRow
            Set sh = Nothing
            On Error Resume Next
            Set sh = Worksheets(.Cells(i, ii).Value)
            If Err <> 0 Then Err.Clear
            If sh Is Nothing Then
                Worksheets.Add after:=Worksheets(Worksheets.Count)
                Set sh = ActiveSheet
                sh.Name = .Cells(i, ii).Value
                .Rows(1).Copy sh.Cells(1) 'modif
            End If
            NextRow = sh.Cells(sh.Rows.Count, ii).End(xlUp).Row + 1
            .Rows(i).Copy sh.Cells(NextRow, 1)  'modif
        Next i
    End With
    With Application
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
Ender:
End Sub

Cordialement.

PMO
Patrick Morange
 

Discussions similaires

Réponses
12
Affichages
299

Statistiques des forums

Discussions
312 500
Messages
2 089 013
Membres
104 004
dernier inscrit
mista