Hello people,
I have made a very long code....
But I want to make it shorter, but I don't know how...
I got thoughts about create a kind of an array/case/for loop instead,
have someone a suggestion how to make this code shorter?
Thank you in advance
I have made a very long code....
But I want to make it shorter, but I don't know how...
I got thoughts about create a kind of an array/case/for loop instead,
have someone a suggestion how to make this code shorter?
Code:
Sub GetColData()
'This function Get all the column data from the "Company" sheet.
' If name "xxx" then copy following sheets to current workbook.
For Each sht In ThisWorkbook.Worksheets
mysheetname = sht.Name
If sht.Name Like "Volvo_3P*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
If sht.Name Like "Volvo_Penta*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
If sht.Name Like "Volvo_Bus*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
If sht.Name Like "Volvo_Business_Service*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
If sht.Name Like "Volvo_Group_Trucks_Technology*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
If sht.Name Like "Volvo_Information_Technology_AB*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
If sht.Name Like "Volvo_Group_Sweden*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
If sht.Name Like "Volvo_IT*" Then
Sheets(mysheetname).Select
Columns("A:A").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("A:A").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("C:C").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("D:D").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("D:D").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("H:H").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("E:E").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("I:I").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("G:G").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("J:J").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("H:H").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("K:K").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("I:I").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("L:L").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("J:J").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("M:M").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("E:E").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("K:K").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("F:F").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("M:M").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("U:U").Select
ActiveSheet.Paste
Sheets(mysheetname).Select
Columns("O:O").Select
Selection.Copy
Sheets("Target_sheet").Select
Columns("AB:AB").Select
ActiveSheet.Paste
End If
Next sht
End Sub
Thank you in advance