Hi There,
I'm trying to write a macro that loops through all the new worksheets in a "master" workbook and copies the necessary data to another worksheet. Since the cells don't match completely, I have to map so that:
the value in column A copies to column C
the value in column C copies to column B
the value in column N copies to column M
The problem i'm having is that the loop is jumping certain lines of code I have written. I built an array as per another earlier thread which had a similar issue. However this problem is different as the macro has to loop through worksheets as well as looping whithin the worksheet itself. Please see code below...The code starts skipping as of the bolded lines....THANKS!
[ufCODE]Sub WorksheetLoop()
Dim WS_Count As Integer
Dim I As Integer
Dim x As Integer
Dim j As Integer
Dim LastRow As Long
Dim ar As Variant
Dim arr As Variant
WS_Count = ActiveWorkbook.Worksheets.Count
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
ar = Array("A", "C", "N")
arrn = Array("C", "B", "M")
Sheets("Margin Adj_Flex upl. F").Range("a4:t500").ClearContents
For I = 4 To WS_Count
For x = 19 To (LastRow - 1)
If Range("L" & x) <> "" And Range("L" & x) <> "0" Then
For j = 0 To 5
Range(ar(j) & x).Copy Sheets("Margin Adj_Flex upl. F").Range(arr(j) & Rows.Count).End(xlUp)(2)
Next j
End If
Next x
Next I
End Sub
[/ufCODE]