danbates77
Board Regular
- Joined
- Jan 10, 2017
- Messages
- 52
- Office Version
- 2016
Hi,
Please can someone help me?
I have 7 palletisers at work (G,H,J,K,L,M & N) and each palletiser has 40 programs (1-40).
I would like to have a sheet (DATA) where I can compare up to 10 programs side by side (C1:L1 for the palletiser letter and C2:L2 for palletiser number) at any one time from any palletiser.
I have created my sheet and I have coded 1 palletiser so far but the way I know how to do it means I have 40 lines of code per palletiser.
I was wondering if someone could take a look and see if you know how to shorten it?
Hope this makes sense and any help would be appreciated
Thanks
Dan
Please can someone help me?
I have 7 palletisers at work (G,H,J,K,L,M & N) and each palletiser has 40 programs (1-40).
I would like to have a sheet (DATA) where I can compare up to 10 programs side by side (C1:L1 for the palletiser letter and C2:L2 for palletiser number) at any one time from any palletiser.
I have created my sheet and I have coded 1 palletiser so far but the way I know how to do it means I have 40 lines of code per palletiser.
I was wondering if someone could take a look and see if you know how to shorten it?
VBA Code:
Sub Check_Palletiser_Program_Number()
Application.EnableEvents = False
If Range("C1") = "" Or Range("C2") = "" Then Range("C4:C37").ClearContents
If Range("C1") = "G" And Range("C2") = "1" Then Range("C4:C37").Value = Sheets("G").Range("C4:C37").Value
If Range("C1") = "G" And Range("C2") = "2" Then Range("C4:C37").Value = Sheets("G").Range("D3:D37").Value
If Range("C1") = "G" And Range("C2") = "3" Then Range("C4:C37").Value = Sheets("G").Range("E4:E37").Value
If Range("C1") = "G" And Range("C2") = "4" Then Range("C4:C37").Value = Sheets("G").Range("F4:F37").Value
If Range("C1") = "G" And Range("C2") = "5" Then Range("C4:C37").Value = Sheets("G").Range("G4:G37").Value
If Range("C1") = "G" And Range("C2") = "6" Then Range("C4:C37").Value = Sheets("G").Range("H4:H37").Value
If Range("C1") = "G" And Range("C2") = "7" Then Range("C4:C37").Value = Sheets("G").Range("I4:I37").Value
If Range("C1") = "G" And Range("C2") = "8" Then Range("C4:C21").Value = Sheets("G").Range("J4:J37").Value
If Range("C1") = "G" And Range("C2") = "9" Then Range("C4:C21").Value = Sheets("G").Range("K4:K37").Value
If Range("C1") = "G" And Range("C2") = "10" Then Range("C4:C21").Value = Sheets("G").Range("L4:L37").Value
If Range("C1") = "G" And Range("C2") = "11" Then Range("C4:C21").Value = Sheets("G").Range("M4:M37").Value
If Range("C1") = "G" And Range("C2") = "12" Then Range("C4:C21").Value = Sheets("G").Range("N4:N37").Value
If Range("C1") = "G" And Range("C2") = "13" Then Range("C4:C21").Value = Sheets("G").Range("O4:O37").Value
If Range("C1") = "G" And Range("C2") = "14" Then Range("C4:C21").Value = Sheets("G").Range("P4:P37").Value
If Range("C1") = "G" And Range("C2") = "15" Then Range("C4:C21").Value = Sheets("G").Range("Q4:Q37").Value
If Range("C1") = "G" And Range("C2") = "16" Then Range("C4:C21").Value = Sheets("G").Range("R4:R37").Value
If Range("C1") = "G" And Range("C2") = "17" Then Range("C4:C21").Value = Sheets("G").Range("S4:S37").Value
If Range("C1") = "G" And Range("C2") = "18" Then Range("C4:C21").Value = Sheets("G").Range("T4:T37").Value
If Range("C1") = "G" And Range("C2") = "19" Then Range("C4:C21").Value = Sheets("G").Range("U4:U37").Value
If Range("C1") = "G" And Range("C2") = "20" Then Range("C4:C21").Value = Sheets("G").Range("V4:V37").Value
If Range("C1") = "G" And Range("C2") = "21" Then Range("C4:C21").Value = Sheets("G").Range("W4:W37").Value
If Range("C1") = "G" And Range("C2") = "22" Then Range("C4:C21").Value = Sheets("G").Range("X4:X37").Value
If Range("C1") = "G" And Range("C2") = "23" Then Range("C4:C21").Value = Sheets("G").Range("Y4:Y37").Value
If Range("C1") = "G" And Range("C2") = "24" Then Range("C4:C21").Value = Sheets("G").Range("Z4:Z37").Value
If Range("C1") = "G" And Range("C2") = "25" Then Range("C4:C21").Value = Sheets("G").Range("AA4:AA37").Value
If Range("C1") = "G" And Range("C2") = "26" Then Range("C4:C21").Value = Sheets("G").Range("AB4:AB37").Value
If Range("C1") = "G" And Range("C2") = "27" Then Range("C4:C21").Value = Sheets("G").Range("AC4:AC37").Value
If Range("C1") = "G" And Range("C2") = "28" Then Range("C4:C21").Value = Sheets("G").Range("AD4:AD37").Value
If Range("C1") = "G" And Range("C2") = "29" Then Range("C4:C21").Value = Sheets("G").Range("AE4:AE37").Value
If Range("C1") = "G" And Range("C2") = "30" Then Range("C4:C21").Value = Sheets("G").Range("AF4:AF37").Value
If Range("C1") = "G" And Range("C2") = "31" Then Range("C4:C21").Value = Sheets("G").Range("AG4:AG37").Value
If Range("C1") = "G" And Range("C2") = "32" Then Range("C4:C21").Value = Sheets("G").Range("AH4:AH37").Value
If Range("C1") = "G" And Range("C2") = "33" Then Range("C4:C21").Value = Sheets("G").Range("AI4:AI37").Value
If Range("C1") = "G" And Range("C2") = "34" Then Range("C4:C21").Value = Sheets("G").Range("AJ4:AJ37").Value
If Range("C1") = "G" And Range("C2") = "35" Then Range("C4:C21").Value = Sheets("G").Range("AK4:AK37").Value
If Range("C1") = "G" And Range("C2") = "36" Then Range("C4:C21").Value = Sheets("G").Range("AL4:AL37").Value
If Range("C1") = "G" And Range("C2") = "37" Then Range("C4:C21").Value = Sheets("G").Range("AM4:AM37").Value
If Range("C1") = "G" And Range("C2") = "38" Then Range("C4:C21").Value = Sheets("G").Range("AN4:AN37").Value
If Range("C1") = "G" And Range("C2") = "39" Then Range("C4:C21").Value = Sheets("G").Range("AO4:AO37").Value
If Range("C1") = "G" And Range("C2") = "40" Then Range("C4:C21").Value = Sheets("G").Range("AP4:AP37").Value
Application.EnableEvents = True
End Sub
Hope this makes sense and any help would be appreciated
Thanks
Dan