Hi. I'm unfamiliar with looping and am having trouble understanding the literature. Could someone please help me with this problem:
I have a command that exports 2 crosstab queries to excel in different spots. My problem is that the 2nd crosstab is out of order (for good reason). There are 10 columns, each with a heading. I need to search range 2 (the 2nd crosstab query) for each heading in range 1 and move a specific dataset to that column in range 1.
Here is the code I've written. It's only able to search for one value and move it to a specific spot:
Code:
Set rng = wks.Range("C" & Lrow + 20, "L" & Lrow + 20)
For Each Cel In rng
If Cel.Value = wks.Range("C1") Then
Cel.Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(10, 0)).Select
Selection.Cut _
Destination:=wks.Range("C" & Lrow1 + 7)
End If
Next Cel
Is there any way to modify this code to loop through range 1 searching range 2 for each heading and moving it to the appropriate column? Otherwise I'll have to paste this code 10 times...