Good afternoon,
Let me set the scene, I undergo projects in iterations as I am learning on the way. I am not experienced enough yet to tackle the whole project altogether, so I break it down to smaller more managable tasks.
I have hundreds of sheets, but only a few are relevant here today. On the sheet named (Consumer Logs) we have a list of clients in column A, from A5 down, and that list is expanding.
I am setting up an index for each of these clients, with sheets created for each client, that will be accessible from this name in column A via a hyperlink.
I can probably sort the hyperlink step shortly, no worries, however I am stuck at a previous step.
At present, I have the list of clients from A5 down (to about A271 but that's irrevelant), and the coding to move it not to another sheet yet (that's the next step) but to only the next column or two depending on what the data in another cell starts with.
For example, A5 has Bob Ainslie 23/12/76, A6 Charlie Allsworth 12/03/82, A7 Andrew Aman 01/01/91. This list is alphabetised by the surname than the first name elsewhere, I have brought it here for my convenience.
Column B has the surnames, so B5 is Ainslie, B6 Allsworth, A7 Aman. I put this here for the ease of having the surname more accessible for my coding (rather than being located halfway through a string where two first names could mess up any attempt at getting the middle).
What I am trying to is do is to list each person's name (sorted by their surname) under different columns. In C4 I have "A". In D4 I have "B". In E4 I have "C". All the way to AB which has "Z".
I have sort of got the code to do that, but there are errors. For some reason when I run the code, the first name with a surname sometimes enters in the cell above where it should be located. This could have something to do with the fact I have around 25 nested If - Else statements. Possibly too many operations going on messing up the cell destinations.
I know there is a way to get rid of that many If's by making another array and loop or something, but it is a little bit past me at present.
Here's the code.
Private Sub SortNames()
Dim rSourceRange As Range
Dim rDestinRange As Range
Dim sLResult As String
Dim i As Integer
'Dim iA As Integer
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("B5:B" & Cells(Rows.Count, "B").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("C5:C" & Cells(Rows.Count, "C").End(xlUp).Row)
For i = 1 To rSourceRange.Count
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("B5:B" & Cells(Rows.Count, "B").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("C5:C" & Cells(Rows.Count, "C").End(xlUp).Row)
If Left(rSourceRange(i, 1).Value, 1) = "A" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("C5:C" & Cells(Rows.Count, "C").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "B" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("D5:D" & Cells(Rows.Count, "D").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "C" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("E5:E" & Cells(Rows.Count, "E").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "D" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("F5:F" & Cells(Rows.Count, "F").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "E" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("G5:G" & Cells(Rows.Count, "G").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "F" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("H5:H" & Cells(Rows.Count, "H").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "G" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("I5:I" & Cells(Rows.Count, "I").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "H" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("J5:J" & Cells(Rows.Count, "J").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "I" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("K5:K" & Cells(Rows.Count, "K").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "J" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("L5:L" & Cells(Rows.Count, "L").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "K" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("M5:M" & Cells(Rows.Count, "M").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "L" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("N5:N" & Cells(Rows.Count, "N").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "M" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("O5:O" & Cells(Rows.Count, "O").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "N" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("P5:P" & Cells(Rows.Count, "P").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "O" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("Q5:Q" & Cells(Rows.Count, "Q").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "P" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("R5:R" & Cells(Rows.Count, "R").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "Q" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("S5:S" & Cells(Rows.Count, "S").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "R" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("T5:T" & Cells(Rows.Count, "T").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "S" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("U5:U" & Cells(Rows.Count, "U").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "T" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("V5:V" & Cells(Rows.Count, "V").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "U" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("W5:W" & Cells(Rows.Count, "W").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "V" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("X5:X" & Cells(Rows.Count, "X").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "W" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("Y5:Y" & Cells(Rows.Count, "Y").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "X" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("Z5:Z" & Cells(Rows.Count, "Z").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "Y" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("AA5:AA" & Cells(Rows.Count, "AA").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "Z" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("AB5:AB" & Cells(Rows.Count, "AB").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next i
End Sub
Let me set the scene, I undergo projects in iterations as I am learning on the way. I am not experienced enough yet to tackle the whole project altogether, so I break it down to smaller more managable tasks.
I have hundreds of sheets, but only a few are relevant here today. On the sheet named (Consumer Logs) we have a list of clients in column A, from A5 down, and that list is expanding.
I am setting up an index for each of these clients, with sheets created for each client, that will be accessible from this name in column A via a hyperlink.
I can probably sort the hyperlink step shortly, no worries, however I am stuck at a previous step.
At present, I have the list of clients from A5 down (to about A271 but that's irrevelant), and the coding to move it not to another sheet yet (that's the next step) but to only the next column or two depending on what the data in another cell starts with.
For example, A5 has Bob Ainslie 23/12/76, A6 Charlie Allsworth 12/03/82, A7 Andrew Aman 01/01/91. This list is alphabetised by the surname than the first name elsewhere, I have brought it here for my convenience.
Column B has the surnames, so B5 is Ainslie, B6 Allsworth, A7 Aman. I put this here for the ease of having the surname more accessible for my coding (rather than being located halfway through a string where two first names could mess up any attempt at getting the middle).
What I am trying to is do is to list each person's name (sorted by their surname) under different columns. In C4 I have "A". In D4 I have "B". In E4 I have "C". All the way to AB which has "Z".
I have sort of got the code to do that, but there are errors. For some reason when I run the code, the first name with a surname sometimes enters in the cell above where it should be located. This could have something to do with the fact I have around 25 nested If - Else statements. Possibly too many operations going on messing up the cell destinations.
I know there is a way to get rid of that many If's by making another array and loop or something, but it is a little bit past me at present.
Here's the code.
Private Sub SortNames()
Dim rSourceRange As Range
Dim rDestinRange As Range
Dim sLResult As String
Dim i As Integer
'Dim iA As Integer
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("B5:B" & Cells(Rows.Count, "B").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("C5:C" & Cells(Rows.Count, "C").End(xlUp).Row)
For i = 1 To rSourceRange.Count
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("B5:B" & Cells(Rows.Count, "B").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("C5:C" & Cells(Rows.Count, "C").End(xlUp).Row)
If Left(rSourceRange(i, 1).Value, 1) = "A" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("C5:C" & Cells(Rows.Count, "C").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "B" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("D5:D" & Cells(Rows.Count, "D").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "C" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("E5:E" & Cells(Rows.Count, "E").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "D" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("F5:F" & Cells(Rows.Count, "F").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "E" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("G5:G" & Cells(Rows.Count, "G").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "F" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("H5:H" & Cells(Rows.Count, "H").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "G" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("I5:I" & Cells(Rows.Count, "I").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "H" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("J5:J" & Cells(Rows.Count, "J").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "I" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("K5:K" & Cells(Rows.Count, "K").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "J" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("L5:L" & Cells(Rows.Count, "L").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "K" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("M5:M" & Cells(Rows.Count, "M").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "L" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("N5:N" & Cells(Rows.Count, "N").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "M" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("O5:O" & Cells(Rows.Count, "O").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "N" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("P5:P" & Cells(Rows.Count, "P").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "O" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("Q5:Q" & Cells(Rows.Count, "Q").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "P" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("R5:R" & Cells(Rows.Count, "R").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "Q" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("S5:S" & Cells(Rows.Count, "S").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "R" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("T5:T" & Cells(Rows.Count, "T").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "S" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("U5:U" & Cells(Rows.Count, "U").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "T" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("V5:V" & Cells(Rows.Count, "V").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "U" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("W5:W" & Cells(Rows.Count, "W").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "V" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("X5:X" & Cells(Rows.Count, "X").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "W" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("Y5:Y" & Cells(Rows.Count, "Y").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "X" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("Z5:Z" & Cells(Rows.Count, "Z").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "Y" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("AA5:AA" & Cells(Rows.Count, "AA").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
Else
If Left(rSourceRange(i, 1).Value, 1) = "Z" Then
Set rSourceRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("A5:A" & Cells(Rows.Count, "A").End(xlUp).Row)
Set rDestinRange = ActiveWorkbook.Worksheets("Consumer Logs").Range("AB5:AB" & Cells(Rows.Count, "AB").End(xlUp).Row)
rDestinRange(i, 1).Value = rSourceRange(i, 1).Value
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Next i
End Sub