J'ai essayé de chercher sur Internet différentes réponses à cette question mais je ne trouve pas la bonne réponse. J'ai un classur Excel avec des feuilles de calcul représentant chaque jour du mois. Dans chacune de ces feuilles, le format est identique (sauf le samedi et le dimanche) et les feuilles contiennent des statistics d'appel. Il est présenté dans le format suivant:
00:00 00:30 0 4 6 3 4 8 0 1 0 0 0
00:00 00:30 0 0 2 7 4 1 0 0 3 3 0
00:00 00:30 7 0 7 5 2 8 6 1 7 9 0
Je dois copyr ces données en 1 feuille unique qui répertorie toutes datatables. Fondamentalement, il ajoute les nouveldatatables au bas des anciennes données. Donc, ce sera une grande list.
Comment cela peut-il être fait? Tout ce que je peux voir, c'est comment produire un total à partir de données multiples en ajoutant toutes les valeurs set. Je dois simplement énumérer datatables comme une grande list.
EDITION MASSIVE:
Comme lors du dernier entretien avec Iain, les parameters corrects ont été définis. J'ai supprimé les derniers extraits de code car ils ne sont pas corrects. Si quelqu'un est toujours intéressé, vérifiez l'historique des modifications.
J'espère que c'est l'édition finale. 😉
Donc, les conditions requirejses sont les suivantes:
Le sous-programme suivant fera l'affaire.
Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Sub BlackwoodTransfer ()Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Dim Summ As Worksheet, Ws As WorksheetSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Dim ShName As SsortingngSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Dim nRow As LongSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Set Summ = ThisWorkbook.Sheets ("Résumé")Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
ShName = InputBox ("Entrez le mois pour Call Flow en mmmm (c'est-à-dire novembre, etc.):") & "Call Flow"Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
'Renvoie le stream d'appels de novembre.Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Cela signifie qu'il ciblera chaque feuille qui contient November Call Flow dans son nom.Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Application.ScreenUpdating = FalseSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Pour chaque Ws dans ThisWorkbook.WorksheetsSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Si InStr (1, Ws.Name, ShName)> 0 puisSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
'À partir du premier caractère du nom de la feuille, s'il a novembre, alors ...Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
nRow = Summ.Cells (Rows.Count, 1) .End (xlUp) .Row + 1Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
'... obtenez la prochaine ligne vide de la fiche récapitulative ...Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Sélectionnez Case Ws.Cells (Rows.Count, 1) .End (xlUp) .RowSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
'... vérifiez combien de lignes cette fiche qualifiée a ...Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Cas 157Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
'... s'il y a 157 rangs au total ...Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Ws.Range (Cellules (57,1), Cellules (104, 13)). CopieSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
'... copy les lignes 57 à 104, 13 colonnes de large ...Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Summ.Range ("A" & nRow) .PasteSpecial xlPasteAllSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
'... et collez à la prochaine ligne vide dans la fiche récapitulative.Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Cas 41Sub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Ws.Range (Cellules (23,1), Cellules (126, 13)). CopieSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Summ.Range ("A" & nRow) .PasteSpecial xlPasteAllSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Autre casSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Ws.Range (Cellules (23,1), Cellules (30, 13)). CopieSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Summ.Range ("A" & nRow) .PasteSpecial xlPasteAllSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Fin ChoisirSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Next WsSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
Application.ScreenUpdating = TrueSub BlackwoodTransfer() Dim Summ As Worksheet, Ws As Worksheet Dim ShName As Ssortingng Dim nRow As Long Set Summ = ThisWorkbook.Sheets("Summary") ShName = InputBox("Enter month for Call Flow in mmmm format (ie. November, etc.):") & " Call Flow" 'Returns November Call Flow. This means it will target every sheet that has November Call Flow in its name. Application.ScreenUpdating = False For Each Ws In ThisWorkbook.Worksheets If InStr(1, Ws.Name, ShName) > 0 Then 'Starting from first character of the sheet's name, if it has November, then... nRow = Summ.Cells(Rows.Count, 1).End(xlUp).Row + 1 '... get the next empty row of the Summary sheet... Select Case Ws.Cells(Rows.Count, 1).End(xlUp).Row '... check how many rows this qualified sheet has... Case 157 '... if there are 157 rows total... Ws.Range(Cells(57,1),Cells(104,13)).Copy '... copy Rows 57 to 104, 13 columns wide... Summ.Range("A" & nRow).PasteSpecial xlPasteAll '... and paste to next empty row in Summary sheet. Case 41 Ws.Range(Cells(23,1),Cells(126,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll Case Else Ws.Range(Cells(23,1),Cells(30,13)).Copy Summ.Range("A" & nRow).PasteSpecial xlPasteAll End Select End If Next Ws Application.ScreenUpdating = True End Sub
@Iain: vérifiez les commentaires et les references croisées avec la database MSDN. Cela devrait expliquer ce que chaque fonction / méthode fait exactement. J'espère que cela t'aides!
Sub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Sub CombineSheets ()Sub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Dim ws As Worksheet, wsCombine As WorksheetSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Dim rg As RangeSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Dim RowCombine As IntegerSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Définissez wsCombine = ThisWorkbook.Worksheets.Add (ThisWorkbook.Worksheets (1))Sub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
wsCombine.Name = "Combine"Sub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
RowCombine = 1Sub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Pour chaque ws dans ThisWorkbook.WorksheetsSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Si ws.Index <> 1 ThenSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Définir rg = ws.Cells (1, 1) .CurrentRegionSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
rg.Copy wsCombine.Cells (RowCombine, 2)Sub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
wsCombine.Range (Cells (RowCombine, 1), Cells (RowCombine + rg.Rows.Count - 1, 1)) = ws.NameSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
RowCombine = RowCombine + rg.Rows.CountSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
wsCombine.Cells (1, 1) .EntireColumn.AutoFitSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Définir rg = RienSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Set wsCombine = NothingSub CombineSheets() Dim ws As Worksheet, wsCombine As Worksheet Dim rg As Range Dim RowCombine As Integer Set wsCombine = ThisWorkbook.Worksheets.Add(ThisWorkbook.Worksheets(1)) wsCombine.Name = "Combine" RowCombine = 1 For Each ws In ThisWorkbook.Worksheets If ws.Index <> 1 Then Set rg = ws.Cells(1, 1).CurrentRegion rg.Copy wsCombine.Cells(RowCombine, 2) wsCombine.Range(Cells(RowCombine, 1), Cells(RowCombine + rg.Rows.Count - 1, 1)) = ws.Name RowCombine = RowCombine + rg.Rows.Count End If Next wsCombine.Cells(1, 1).EntireColumn.AutoFit Set rg = Nothing Set wsCombine = Nothing End Sub
Créez une feuille de calcul "Sommaire" qui doit contenir toutes datatables fusionnées. Ouvrez ThisWorkBook (appuyez simplement sur ALT + F11 dans votre classur Excel.Une nouvelle window s'ouvrira. Votre nom de la feuille de calcul sera visible sur le côté gauche. Continuez jusqu'à ce que vous voyiez ThisWorkBook) Double-click ThisWorkBook et ajoutez le code suivant:
Sub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Sub SummurizeSheets ()Sub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Dim ws As WorksheetSub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Application.Screenupdating = FalseSub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Feuilles ("Résumé"). ActiverSub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Pour chaque ws dans les feuilles de travailSub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Si ws.Name <> "Résumé" EnsuiteSub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
ws.Range ("F46: O47"). CopierSub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
ActiveSheet.Paste Range ("A65536"). End (xlUp) .Offset (1, 0)Sub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Next wsSub SummurizeSheets() Dim ws As Worksheet Application.Screenupdating = False Sheets("Summary").Activate For Each ws In Worksheets If ws.Name <> "Summary" Then ws.Range("F46:O47").Copy ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0) End If Next ws End Sub
Sub AddToMaster () 'cette macro entre dans le classur principal Dim wsMaster As Worksheet, wbDATA As Workbook Dim NextRow As Long, LastRow As Long Dim FileName comme Ssortingng Dim FolderPath As Ssortingng Dim n As Long Dim i
Définir wsMaster = ThisWorkbook.Sheets ("Sheet1")
'Spécifiez le path du dossier
FolderPath = "D: \ work \"
'spécifiant le nom du file
FileName = Dir (FolderPath & " .xls ")
Do While FileName <> ""
NextRow = wsMaster.Range ("A" et Rows.Count) .End (xlUp) .Row + 1
Définissez wbDATA = Workbooks.Open (FolderPath & FileName)
With wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
Avec wbDATA.Sheets ("product_details")With wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
LastRow = .Range ("A" et .Rows.Count) .End (xlUp) .RowWith wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
'Si LastRow> 5 ThenWith wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
Pour i = 2 à LastRowWith wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
.Range ("A2: j" & i) .CopyWith wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
wsMaster.Range ("A" et NextRow) .PasteSpecial xlPasteValuesWith wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
'Set NextRow = NextRowWith wbDATA.Sheets("product_details") LastRow = .Range("A" & .Rows.Count).End(xlUp).Row ' If LastRow > 5 Then For i = 2 To LastRow .Range("A2:j" & i).Copy wsMaster.Range("A" & NextRow).PasteSpecial xlPasteValues 'Set NextRow = NextRow Next i End With
FileName = Dir () Loop
wbDATA.Close False End Sub