Hi I have got the following code from someone else
This basically takes all columns from all worksheets in excel and pastes it into 1 column.
the problem is I don't understand the code, I want to know how I search google to learn what this code is doing
so I understand until line 11 but then I get lost
I am assuming Lines 13 and 20 say do the following code in each worksheet
then line 14 says in the current worksheet do the code begining in line 15
Line 15 Queries:
Query 1: "For Each rCell": Where is rCell given a value?
Query 2: For the rest of the code I assume its saying make the range from B1 to whatever the last column number is.
Line 16 Queries:
Query 1: I have no idea whats going on here
Line 17 Queries:
Query 1: I have no idea whats going on here
My objective is similar to this code but I want excel to take each consecutive set of 3 columns and paste it into the first 3 columns e.g.: take Column D,E and F and paste them underneath A,B and C. Then take Columns G, H and I also page them underneath A,B and C, and on it goes until all columns are pasted under Columns A, B and C.
Thank You
Code:
Sub MultiColsToA()
Dim rCell As Range
Dim lRows As Long
Dim lCols As Long
Dim lCol As Long
Dim ws As Worksheet
Dim wsNew As Worksheet
lCols = Columns.Count
lRows = Rows.Count
Set wsNew = Sheets.Add()
For Each ws In Worksheets
With ws
For Each rCell In .Range("B1", .Cells(1, lCols).End(xlToLeft))
.Range(rCell, .Cells(lRows, rCell.Column).End(xlUp)).Cut _
wsNew.Cells(lRows, 1).End(xlUp)(2, 1)
Next rCell
End With
Next ws
End Sub
the problem is I don't understand the code, I want to know how I search google to learn what this code is doing
so I understand until line 11 but then I get lost
I am assuming Lines 13 and 20 say do the following code in each worksheet
then line 14 says in the current worksheet do the code begining in line 15
Line 15 Queries:
Query 1: "For Each rCell": Where is rCell given a value?
Query 2: For the rest of the code I assume its saying make the range from B1 to whatever the last column number is.
Line 16 Queries:
Query 1: I have no idea whats going on here
Line 17 Queries:
Query 1: I have no idea whats going on here
My objective is similar to this code but I want excel to take each consecutive set of 3 columns and paste it into the first 3 columns e.g.: take Column D,E and F and paste them underneath A,B and C. Then take Columns G, H and I also page them underneath A,B and C, and on it goes until all columns are pasted under Columns A, B and C.
Thank You
Comment